Hi there!
User story:
As $user I want to know when my weather station has stopped and are not updating the weather station values anymore.
To solve this I planned to count the times the weather station is sending the same value and if it is still sending the n time I'll notify.
If it's updated I'll reset the counter value to n=1
Here's my built out Blockly in Events:
(truncated the notification line...)
Unfortunately, as you can see, I'm missing the option to update the value of +1
but it is possible here:
https://developers.google.com/blockly/g ... eb/toolbox
Now, I'm sure there are other ways and probably smarter ways but as I'm not too good at writing my own scripts this is the solution I went for.
Are there any chance I can update the value as I wish with Blocky and Events in Domoticz or do I need to work with LUA or even turn to node-red?
Do I just not find the blocks or is it possible to add these functions into Events for Domoticz?
Many Thanks!
Edit: Placed attachments on the right place.
UPDATE: Added to my Blockly IF to reset the counter SET, Counter = 0, when message is sent
Blockly: Update value from blocky with a forumla (value + 1)
Moderator: leecollings
Re: Blockly: Update value from blocky with a forumla (value + 1)
Hi,
for some testing purposes I created a virtual text sensor called Counter, I gave it value "0". The following LUA script reads the value, turns it into a number and when my PushOnButton is pressed, it adds 1 to the number and writes the value as a string into the text sensor (the idx of the sensor = 2). This way I can tell how often the button is pressed and it is shown on the Utility tab. Maybe you can use this as an example and create your own solution.
for some testing purposes I created a virtual text sensor called Counter, I gave it value "0". The following LUA script reads the value, turns it into a number and when my PushOnButton is pressed, it adds 1 to the number and writes the value as a string into the text sensor (the idx of the sensor = 2). This way I can tell how often the button is pressed and it is shown on the Utility tab. Maybe you can use this as an example and create your own solution.
Code: Select all
counter = otherdevices_svalues['Counter']
counter = tonumber(counter)
commandArray = {}
if
devicechanged['PushOnButton'] == 'On'
then
counter = counter + 1
commandArray['UpdateDevice'] = 2 .. '|0|' .. tostring(counter)
end
return commandArray
- MadMedic
- Posts: 31
- Joined: Wednesday 26 October 2016 14:06
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Huizen, the Netherlands
- Contact:
Re: Blockly: Update value from blocky with a forumla (value + 1)
Thnx mrf08,
Reviving an old thread. Nevertheless this script was just what I was looking for.
Now for the next challenge:
only update the counter when button isn't pressed for at least half an hour or more.
(Or in my case, the backdoor isn't opened in more then half an hour.)
And resetting the count @ midnight
In any case: ^5 on leading me from blocky to lua
Reviving an old thread. Nevertheless this script was just what I was looking for.
Now for the next challenge:
only update the counter when button isn't pressed for at least half an hour or more.
(Or in my case, the backdoor isn't opened in more then half an hour.)
And resetting the count @ midnight
In any case: ^5 on leading me from blocky to lua
.
"Life is too short for bad coffee"
"Life is too short for bad coffee"
Who is online
Users browsing this forum: No registered users and 1 guest