@TotallyInformation
Sometimes you have to know when to give up.
I have been reading all night about things like declaring reactive properties and I have tried it all e.g. using the $set method instead of what I was doing originally which apparently does not create a reactive property.
Where this all started
I didn't want to hardcode all my light names etc and write my code in a way that I have to hardcode test each light individually ie. repeating the same code over and over again, however in the end I may have built 50% more if I'd just done that. haha!!!
So I created variables for each light and for each key value I needed to store. I then wrote my code to work off the variables, however I hit a stumbling block.
I needed to lookup a string = the variable name e.g. this string "brightness_avmain" sits in another variable. I then needed to test the value of the variable = brightness_avmain. This is why I tried to use eval() in the first instance, but it looks like you can only use eval() on the right hand side of the equals sign.... ie I can't get eval() to work and when I read up more on it I keep getting scared away from using it.... seems like it's bad voodoo.
Then I moved to name/value pairs thinking very cleverly that I had sorted it all out, but then came the reactive issues. I came up with a hack which I'm almost wishing I'd explored more which was to update one of the other key variables each time I did any variable updates... this kind of seemed to work, but I stopped as it felt like a nasty hack.
So back to all that reading up tonight. Including this website amongst many:https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties
I tried everything I came across including $set, but could not get anything to fully function
app1.$set(app1.values, app1.values[device_lookup.colourname], msg.colour)
Basically I just haven't been able to figure out how to make a key/value or name/value (depending on where you come from) pair array, like the one below, reactive ie make it so it updates the web page straight away
values: [{brightness_avmain:"10",
brightness_avspots:"11",
brightness_skylight:"12",
colour_skylight:"#000000"},
],
BTW: I tried curly brackets around each name/value and just one pair of curly brackets around the lot and I can't see any difference. I'm sure there is one, but it ain't working any differently at the front end.
So after fight and losing, in the end I gave up, and hacked it... haha. Yes, I didn't want to hack it to start with, but I've given in and hacked it!!!... I think this hack is better anyway
So, I have gone back to my boring old variables e.g.
brightness_avmain:"10",
brightness_avspots:"11",
brightness_skylight:"12",
colour_skylight:"#000000",
BUT I have also kept the name/value pair array above. I now update both, why might you ask?
This way I can reference the boring old variables in my HTML (which works i.e. the values update correctly the first time) and I can also test the value of a string, which I can do with an array that is a name/value pair....
I'm sure there is a better way, but I've burnt many hours now to get where I am and at the end of the day it works!!!
Onto the next task. woo hoo!!!!
All I need now is some clever cloggs to come in and say, it's really easy you only have to do x, y and z.... Don't do it. I don't want to know. I have to move on... haha!