For switches you can use
toggle switch1
Would be nice to do this with dimmers also. Just like dimming to 0% and 100% or even to the last dimlevel that was higher than 0%
Toggle dimmers
For switches you can use
toggle switch1
Would be nice to do this with dimmers also. Just like dimming to 0% and 100% or even to the last dimlevel that was higher than 0%
You meen in rules?
dim couch-light to 30%
Follow my domotica project on http://maredana.nl
no, he want’s the action ‘toggle’ for dimmers, too. Atm a dimmer device has only the changeDimlevelTo
and changeStateTo
actions.
I don’t have a dimmer device, but imo a toggle action would be very useful (especially the return to last dimlevel, if > 0)
@sweebee I think it would be possible to do something like that with scripts or rules but an action would be easier
Isn;t this also dependend on the device? If I send a ON command to a KaKu dimmer, the KaKu device itself returns to the last dim state.
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
@SLiX said:
Atm a dimmer device has only the changeDimlevelTo and changeStateTo actions.
Well, no. The DimmerActuator
also supports turnOn
and turnOff
where turnOn
will set the dimlevel to 100%.
@koffienl said:
Isn;t this also dependend on the device? If I send a ON command to a KaKu dimmer, the KaKu device itself returns to the last dim state.
Good point. There are several subclasses & implementations of “dimmer” which may vary in behaviour. With HomeduinoRFDimmer
, for example, the turnOn method will set the dimlevel to @_lastdimlevel (in contrast to the aforementioned 100% of the DimmerActuator
).
It should be possible though to provide a generic toggle method implementation as part of the DimmerActuator
which is inherited by the various dimmer subclasses - I guess we have about 15 dimmer subclasses out there.
Here is what the toogle() method might look like:
toggle: ->
@getDimlevel().then( (level) =>
if level > 0
@turnOff()
else
@turnOn()
)
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@mwittig said:
Well, no. The
DimmerActuator
also supportsturnOn
andturnOff
whereturnOn
will set the dimlevel to 100%.
Did not mention them, cause it’s obvious that this actions exist.
Sorry for my unclear post, and thanks for correction!
Maybe you can think about what @sweebee said:
or even to the last dimlevel that was higher than 0%
Won’t be hard do get the last value from history (or db) and (if it is != 0) call the changeDimLevelTo
(since it includes turnon if state is False) instead of @turnon
, isnt it?
@SLiX said:
Won’t be hard do get the last value from history
I disagree on this as this is a matter of the turnOn() implementation. The toggle() implementation should be generic as outlined above.
Of couse, the turnOn() method can changed to implement the suggested behaviour for the DimmerActuator, but this should be seen as separate feature request.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
Wow, a lot going on here
The dimmer already supports turn on and turn off. so toggle should just ‘toggle’ between these on en off.
For dimming to the last dim level its more complicated i guess?
for lights in rooms where they get triggered by a pir i can create 1 rule with toggle. But since i replaced almost all my lights with hue’s, i have to create 2 separate rules because they are dimmers.
example with a switch:
IF:
[[light of woonkamer-ldr <= 80 or its after sunset or its before sunrise] and trigger: hal-pir is present and state of hal-lamp equals Uit] or [trigger: hal-pir is absent and state of hal-lamp equals Aan]
THEN:
toggle hal-lamp
I can’t do this with dimmers.
@sweebee said:
The dimmer already supports turn on and turn off. so toggle should just ‘toggle’ between these on en off.
Yes. See code snippet in one of my earlier posts.
For dimming to the last dim level its more complicated i guess?
As this is part of the turnOn() method implementation there are several implementations of it which exhibit varying behaviour. “With HomeduinoRFDimmer, for example, the turnOn method will set the dimlevel to @_lastdimlevel (in contrast to the aforementioned 100% of the DimmerActuator).”.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@mwittig thanks for the little code. added it to devices.coffee and its working I’ll create a pull request.