Trigger a blocky event on TEXT custom sensor change

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
multinet
Posts: 97
Joined: Friday 05 December 2014 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Trigger a blocky event on TEXT custom sensor change

Post by multinet »

Hello

I've a text custom sensor and I want to run an event when this TEXT sensor change to a specific value

I've made a blocky event type DEVICE -> does not run
I tried every type same result

Is it possible to do that on domoticz ?

Thank you
PI 2 - Domoticz 2021.1
RFXCOM - RFXtrx433 USB 433.92MHz Transceiver (5 DIO 54755 + 2 DIO 54756 + 3 DIO 54798)
Z-Wave.Me ZME_UZB1 USB Stick (6 FGSD002 + 2 FGRM222 + 1 FGS223 + 1 FGMS001-ZW5 + 1 FGRGBWM441 + 1 FGBS001 + 2 FGFS101)
6 sondes DS18B20
Sushukka
Posts: 12
Joined: Saturday 10 December 2016 23:21
Target OS: -
Domoticz version:
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by Sushukka »

Sorry I have no answer to this but want to bump this topic as I'm banging my head with the same thing.
I'm using MySensors and there have been several occasions when I want to pass some variable or parameter back to the node. For example, I have a led strip which has multiple animation modes. Using selector on Domo to change the text sensor status and you could pass parameters to the node.

In MySensors you define the messages and present the sensors to Domoticz. For receiveing data you need naturally define receive functions what to do when receiving data from Domo. So far have over hundred sensor in the house and all the bulk stuff runs just fine, but why in the earth Domoticz cannot inform MySensors node when V_TEXT/S_INFO sensor is updated!? Domo can send that information and MySensors node is just waiting to get that information. Now you have to manually send request (create a dummy, inefficient periodical poll) from node to force Domo to send the data. WHY WHY WHY!?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by waaren »

Sushukka wrote: Thursday 05 April 2018 10:44
... but why in the earth Domoticz cannot inform MySensors node when V_TEXT/S_INFO sensor is updated!? Domo can send that information and MySensors node is just waiting to get that information. Now you have to manually send request (create a dummy, inefficient periodical poll) from node to force Domo to send the data. WHY WHY WHY!?
If you are willing to use dzVents for this I might be able to help.

What is the (example) command you manually send to MySensors node ?
What are the names of the domoticz V_TEXT/S_INFO devices and on what string / event the command must be send ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Sushukka
Posts: 12
Joined: Saturday 10 December 2016 23:21
Target OS: -
Domoticz version:
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by Sushukka »

waaren wrote: Thursday 05 April 2018 12:23
Sushukka wrote: Thursday 05 April 2018 10:44
... but why in the earth Domoticz cannot inform MySensors node when V_TEXT/S_INFO sensor is updated!? Domo can send that information and MySensors node is just waiting to get that information. Now you have to manually send request (create a dummy, inefficient periodical poll) from node to force Domo to send the data. WHY WHY WHY!?
If you are willing to use dzVents for this I might be able to help.

What is the (example) command you manually send to MySensors node ?
What are the names of the domoticz V_TEXT/S_INFO devices and on what string / event the command must be send ?
I have written some LUA stuff when followed some heatpump IR remote guide (which was addressing similar type of challenge) from this forum, but I have to admit that I'm not a LUA expert.
Usually the sent data is very short, simply some numbers, short text, hex...I would say that if I'm going over MySensors max. payload size (25bytes) there is a mistake somewhere.
So the latest example I have in my hands goes like this:
  • I have a adressable WS2812 strip and using nice WS2812FX library
  • This library has 56 different animation modes
  • In node sketch I have:

    Code: Select all

    MyMessage msgLedMode(LED_MODE_ID, V_TEXT);
    
    void presentation() {
    present(LED_MODE_ID, S_INFO, "HomeNumber LED mode");
    }
    
    void receive(const MyMessage &message) { 
     if (message.type==V_TEXT) {
        if (message.sensor==LED_MODE_ID) {
          String LEDtemp = message.getString();
          ledMode = LEDtemp.toInt();
          if (ledMode == -1)
            setLedOff(); 
          else if (ledMode < 56 && ledMode >= 0)
            setLedMode(ledMode);
        }
      }
    }
    
  • I have created a dummy virtual switch in Domo
  • This dummy virtual switch is selector switch where I have predefined some modes I want use
  • Every selector switch level have an action like:
    http://xxx.xxx.xxx.xxx:pppp/json.htm?type=command&param=udevice&idx=xxx&nvalue=0&svalue=nnn
    where nnn is number between 0-56.
  • So now after clicking my virtual switch selector button, the LED_MODE_ID / V_TEXT sensor will be updated to have the requested LED animation mode I want to run...and yes this update happens only on Domoticz level. No updates will be triggered to send the data to the actual node.
By building the process like this, I can change the available LED modes directly in Domoticz without making any changes to the actual sketch running on ESP8266. Now this works very well if I put an interval poll in the sketch loop. Problem with this node is that it has also an IR remote functionality where I have similar setup than above but it just passes IR commands to my amplifier and projector etc. Therefore the response time has to be fast enough so that when an IR command is given, one don't have to wait tens of seconds before something happens. This means a request command has to be sent about every two or three seconds and that's just too dirty way to solve this... :)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by waaren »

I am still not sure I completely understand what you exact want but maybe this code will help ?

Code: Select all

--[[ 
		test-text (dzVents >= 2.4.0 )
]]--


return {
	on = { devices = { 'test-Text' }},
	

	execute = function(dz, trigger)
		if trigger.text == "openurl" then 
			print (trigger.name .. " is now : " .. trigger.text)
			dz.openURL("http://xxx.xxx.xxx.xxx:pppp/json.htm?type=command&param=udevice&idx=xxx&nvalue=0&svalue=nnn")
		end	
	end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Sushukka
Posts: 12
Joined: Saturday 10 December 2016 23:21
Target OS: -
Domoticz version:
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by Sushukka »

waaren wrote: Sunday 08 April 2018 13:13 I am still not sure I completely understand what you exact want but maybe this code will help ?

Code: Select all

--[[ 
		test-text (dzVents >= 2.4.0 )
]]--


return {
	on = { devices = { 'test-Text' }},
	

	execute = function(dz, trigger)
		if trigger.text == "openurl" then 
			print (trigger.name .. " is now : " .. trigger.text)
			dz.openURL("http://xxx.xxx.xxx.xxx:pppp/json.htm?type=command&param=udevice&idx=xxx&nvalue=0&svalue=nnn")
		end	
	end
}
Does the "execute = function(dz, trigger)" force Domoticz internally to send the text update to MySensors node?
Here is my another attempt to explain the problem :)
  • I can define V_TEXT/S_INFO sensor in MySensors node and present it normally to Domoticz
  • If I update any switch/light/dimmer type of sensors on Domoticz, this information will be passed directly to my MySensors node.
  • If I update V_TEXT sensor in Domoticz, it will be updated in Domoticz's Utility tab, but will never trigger any event to send the actual upate to the node
  • To get the current value from Domoticz TEXT sensor, I have to manually give:
    request(LED_MODE_ID, V_TEXT, 0);
    command in my sketch whereafter Domoticz will send the value and I can read it in the sketch's receive function:

    Code: Select all

     "void receive(const MyMessage &message) { 
      if (message.type==V_TEXT) {
        if (message.sensor==LED_MODE_ID) {
        ...
     ...   
    
  • Problem is that issuing the "request" command every second or two is not an elegant solution and generates lots of overhead.
This seems to be a common problem as ppl have built several more or less dirty workarounds to tackle the issue. For example one workaround I have used/seen is to create a dummylike triggering switch (normal binary/light sensor) sensor on the node. When the text sensor is updated on Domoticz, LUA script will react and update the triggering switch status. This switch change will be passed normally to the node which now knows that the TEXT sensor has been updated and will issue the request command to get the TEXT value...also there is a kind a similar workaround with dimmer sensor and it's different values, but as you can see, all these are just unnecessary tricks to get around a very simple requirement.
Sushukka
Posts: 12
Joined: Saturday 10 December 2016 23:21
Target OS: -
Domoticz version:
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by Sushukka »

Bump for this.
Why is this so hard? This would be a very small update but would help tremendously with all MySensors related stuff. Also MySensors is pretty much the number one home made Arduino/ESP8266 protocol nowadays. Question is still: why Domoticz won't send any update to the the MySensors node or gateway when text sensors is updated in Domo? If you click a switch, change a color, use dimmer etc. Domo will send the update to the node, but not for text sensor. Tested this with OpenHAB and it sends the update like any other two-way sensor. So this is purely Domoticz problem and there are no valid explanation anywhere why it works like this. It just seems to be a peristent bug.

Sorry my negative tone, but getting frustrated to the so common silence here and because this small "feature" is generating lots of extra unnecessary work to many MySensors users.
fargle
Posts: 70
Joined: Tuesday 27 March 2018 17:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Trigger a blocky event on TEXT custom sensor change

Post by fargle »

multinet wrote: Tuesday 27 March 2018 7:51 Hello

I've a text custom sensor and I want to run an event when this TEXT sensor change to a specific value

I've made a blocky event type DEVICE -> does not run
I tried every type same result

Is it possible to do that on domoticz ?
Came across this when looking for a solution. The answer is ...maybe. :) The following may help someone.

I had exactly the same issue with a text sensor. Even though the values reported were correct, couldn't get a script to run based on them.
But found that Blockly would respond to a change in value, so that was used instead. That was good enough in this case, which just switches on a door "Courtesy Light" for a short period at night.
Another oddity - it wouldn't run if an "If/ElseIf" block was used to set additional conditions.

Maybe the result could be used to trigger yet another script, but that seems to be a clumsy way to go.
.
Screenshot_2021-01-01 Domoticz.png
Screenshot_2021-01-01 Domoticz.png (24.58 KiB) Viewed 966 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest