Read text value from one sensor and send to another

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
LastSamurai
Posts: 15
Joined: Wednesday 26 August 2015 1:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Read text value from one sensor and send to another

Post by LastSamurai »

I have two sensors in domoticz that are of the type "General/Text" (based on MySensor nodes). I am trying to write a script that reads the text from sensor1, checks if its part of a list of values and then sends it to sensor 2. This is my code for now:

Code: Select all

return {
        active = true,
        on = {
            '433Receiver'
        },
        execute = function(domoticz, sensor)

            domoticz.log("Received from gateway " .. sensor.state)
            -- check sensor values 
            domoticz.devices['433Sender'].setState(sensor.state)
        end
    }
The text value seems to be in rawData[1], in _sValues and in state. I tried to use setState() but that doesn't seem to be working. The text in the domoticz frontend isn't updated and no message is send to the sensor.

Any help would be great! How can I change and read text sensors?

PS I am using dzVents 1.1.1 I think, haven't updated to 2 yet
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Read text value from one sensor and send to another

Post by dannybloe »

Well, I think this is a classic case of RTFM ;) Device methods. You need the updateText() method to update the text of a text-device.

Give it a try (and upgrade to 2.0 as soon as you can).
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
LastSamurai
Posts: 15
Joined: Wednesday 26 August 2015 1:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read text value from one sensor and send to another

Post by LastSamurai »

@dannybloe thank you very much! I did actually read the manual ;) I don't know how I managed to miss that method. It seems to be working fine now, although no update of the values seem to get send to my MySensors node :(

PS The text value gets updated in the normal ui ("counter" tab? I am using the german version) but not in the hardware tab under the gateway details. Might this be a domoticz problem? Or do I just need some other call in LUA?

I will upgrade in the next days to version 2.
Archer627
Posts: 1
Joined: Wednesday 22 March 2017 1:09
Target OS: Linux
Domoticz version:
Contact:

Re: Read text value from one sensor and send to another

Post by Archer627 »

LastSamurai, did you ever find a solution to your PS - i.e.; that the hardware tab values get updated? I have the same problem and am struggling for an alternative to be able to send data to a node. Thanks.
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read text value from one sensor and send to another

Post by PeterRozenveld »

It does not differ much, I think, what I want.
I am looking for a script , which depending on two power meters (0-3800 Watts Shelly Z-wave) , sets the 0-10Volt Dimmer (Shelly Wifi) to that value percentage-wise as well. (Control Kitchen Extractor) .
But I don't understand most of what is written here !
Can anybody help ?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests