Currently a VariableInputDevice tries to update a simple variable. If you not specify a variable in the config of the VariableInput devices - and this is possible with the UI edit function - an error occurs when trying to change the value of the VariableInputDevice.
In my opinion it is not necessary to have a variable behind the VariableInputDevice. In most cases it is enough to work withthe internal value , e.g. myVariableInputDevice.input . This would also be equal to other device classes. The simple variable behind is redundant.
-
[Implemented] VariableInputDevice without shadow variable
-
Well that’s an interesting idea. I moved
the thread to the feature request forum!pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
@leader21 Thanks. This is not a realy great feature but to remove this restriction would help to simplify working with pimatic and would also make config a bit smaller. I am not a pimatic developer but I guess to implement this is not a great effort. Simply check if the property variable is set and only if true update the coresponding variable.
-
Can some developer point me to the code location(s) where a variable is required for the VariableInputDevice? May be I can remove this check by myself.
-
@Heizelmann See https://github.com/pimatic/pimatic/blob/master/lib/devices.coffee#L800-L827 and https://github.com/pimatic/pimatic/blob/master/device-config-schema.coffee#L72-L97
Looking at your request I think what you want is rather a “DummyInputDevice” than a tweaked “VariableInputDevice”. If you don’t want to reference a variable there is no need to create one on the fly as the device attribute is a variable anyway. So, I think it is better to create an abstract class “InputDevice” with subclasses “VariableInputDevice” and “DummyInputDevice”. The code for “DummyInputDevice” will be jsut a few lines then.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig Thank you for the information. From users point of view I think it is not a good solution to introduce another device class. In general the sytem should kept as easy as possible for the user and one point is the keep number of elements as small as possible.
I have less kowledge about coffeescript but looking at the code you pointed me to I believe that a small change to VariableInputdevice is better than adding a new device class. Here my amateurish suggestion for code change in function changeInputTo:unless name env.logger.warn("Variable not set \"#{@name}\"") else variable = @framework.variableManager.getVariableByName(name) unless variable? throw new Error("Could not find variable with name #{name}") @framework.variableManager.setVariableToValue(name, value, variable.unit)
With this the attribute ‘variable’ can marked as optional.
-
@mwittig What do you think about this?
-
@developers Could this be put as a change request to github? I didn’t like to work too long with temporary local changes.
-
@Heizelmann
fyi, pimatic@0.9.41 contains a new device type “InputDevice” for your needs.It should also fix some of the issues some users experienced with VariableInputDevice, e.g.https://github.com/pimatic/pimatic/issues/1042
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig Thanks a lot, I changed my config and it works perfect
-
@Heizelmann Sounds great! Thanks for the feedback
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law