I want to keep track of the state changes of some devices. I created a "null device" with a property "general count" and I wat that this property is incremeted by 1 when the monitored device changes the state, therefore I'm trying to created a task to change the property of general count by +1 but it does not work. I've tried several expressions as +=1, =+1 and so on.
What do I have to do to increment the counter property?
How to increment a counter
Re: How to increment a counter
That's a good question. I can be done from a script, and easily from a SWRemote with the +=1 notation, but directly from a Task is not as easy. I suppose it's just a huge oversight, but you can't just use +=1.
To do it from a Task, you will need to use Property Value substitution and an extra Property, since you can't assign a property to itself in any way using PV substitution. So the logic would go something like:
To do it from a Task, you will need to use Property Value substitution and an extra Property, since you can't assign a property to itself in any way using PV substitution. So the logic would go something like:
- Change TempNumericProperty (new Property that you must add) to PropertyYouWantToInc (this is done with PV substitution)
- Change PropertyYouWantToInc to TempNumericProperty+1 (again, done with PV substitution)
Scott
Re: How to increment a counter
Thanks for the answer, I am going to try this but in my opinion a counter device is a must for a automation program because you want to keep track of devices.
I am switching a couple of air dryers on and of based on the humidity and the temperature off the rooms and I want to see how many times the are switched on and off in a month or so.
Maybe a counter device as a new device in HouseBot?
I am switching a couple of air dryers on and of based on the humidity and the temperature off the rooms and I want to see how many times the are switched on and off in a month or so.
Maybe a counter device as a new device in HouseBot?
Re: How to increment a counter
With PV substitutions it works, see attached screenshot.
Every time the state is changing to off the switch counter property is incrementing by 1.
Every time the state is changing to off the switch counter property is incrementing by 1.
- Attachments
-
- It's working with 2 varibles
- Counter task.jpg (18.85 KiB) Viewed 2888 times
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: How to increment a counter
Hi Scott,
Is there any plan to add this into the task so we don't have to create extra variables each time?
Thanks
Raptor
Is there any plan to add this into the task so we don't have to create extra variables each time?
Thanks
Raptor
Re: How to increment a counter
Not currently. However, if it is important to you and you think others would value the feature, please add it to the feature request list.
Scott