Page 1 of 1

Change a Switch with a text device

Posted: Tuesday 26 January 2021 21:55
by Svennie
Hello,

I have a text device that gives my the status of my Roomba robot. The status can be "Running", "Stopped" and "End Mission".
I would like to activate a switch based on a status change with blocky.
Schermafbeelding 2021-01-26 om 21.48.22.png
Schermafbeelding 2021-01-26 om 21.48.22.png (56.91 KiB) Viewed 1162 times
I would like to achieved the following:

If RoombaS9 State = Running
do set Dummy test = on

I use a Dummy switch now. When I got the script working I will switch the dummy for a group of lights/ switches.
Schermafbeelding 2021-01-26 om 21.51.38.png
Schermafbeelding 2021-01-26 om 21.51.38.png (43.79 KiB) Viewed 1162 times
This is what I created in Blocky now. But that isn't working.

I hope someone can help me.

Thank you for your help in advance.

greetz ven

Re: Change a Switch with a text device

Posted: Tuesday 26 January 2021 22:30
by waaren
Svennie wrote: Tuesday 26 January 2021 21:55 ... But that isn't working.
According to the tooltip (see below) the block is for assigning a value to a text sensor. You cannot use this block to read the value of a text device. I don't think you can do this in Blockly.
text device.png
text device.png (9.76 KiB) Viewed 1155 times

Re: Change a Switch with a text device

Posted: Wednesday 27 January 2021 18:24
by Svennie
Waaren,

I see we are both Dutchmen. Can we continu in Dutch?

For now I will do it in English.

Is there a way to do what I want in a different way? Beside Blocky?

Thnx

Re: Change a Switch with a text device

Posted: Wednesday 27 January 2021 18:56
by waltervl
You can ask the plugin writer to make it a selector switch instead of a text widget. Then you can set actions on the state change of switch.

Or you can use DzVents scripting to read the status and switch the dummy (or later your lighting group). A lot of examples in the excellent documentation on the wiki https://www.domoticz.com/wiki/DzVents:_ ... _scripting

Re: Change a Switch with a text device

Posted: Wednesday 27 January 2021 19:57
by waaren
Svennie wrote: Wednesday 27 January 2021 18:24 I see we are both Dutchmen. Can we continu in Dutch?
@Svennie, the forum is international so please continue in English. @walterv already answered the question.

Re: Change a Switch with a text device

Posted: Wednesday 27 January 2021 20:35
by Svennie
waltervl wrote: Wednesday 27 January 2021 18:56 You can ask the plugin writer to make it a selector switch instead of a text widget. Then you can set actions on the state change of switch.

Or you can use DzVents scripting to read the status and switch the dummy (or later your lighting group). A lot of examples in the excellent documentation on the wiki https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Hello Waltvl,

Thank you for your response. Can you give me an example of Dzvents script? That I can use in my case? I'm a Noob in Dzvents. I did read the wiki you mentioned but I couldn't find my answer.

Re: Change a Switch with a text device

Posted: Wednesday 27 January 2021 22:31
by waaren
Svennie wrote: Wednesday 27 January 2021 20:35 Can you give me an example of Dzvents script? That I can use in my case? I'm a Noob in Dzvents. I did read the wiki you mentioned but I couldn't find my answer.
Your Blockly converted to a working dzVents script.

Code: Select all

return
{
    on =
    {
        devices =
        {
            'RoombaS9-State', -- Name of your device
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Roomba',
    },

    execute = function(dz, item)
        if item.text == 'Running' then
            dz.devices('Dummy test').switchOn()
        end
    end
}

Re: Change a Switch with a text device

Posted: Friday 29 January 2021 21:42
by Svennie
waaren wrote: Wednesday 27 January 2021 22:31 Your Blockly converted to a working dzVents script.
Waaren,

Thank you for your script. Unfortunately it's not working. I took a look at it. But I didn't find the error or found the solution. Do you have any clue?

Greetz Sven

Re: Change a Switch with a text device

Posted: Friday 29 January 2021 23:04
by waaren
Svennie wrote: Friday 29 January 2021 21:42 Thank you for your script. Unfortunately it's not working. I took a look at it. But I didn't find the error or found the solution. Do you have any clue?
"it's not working" is usually not enough to start looking for a root cause :D
  • did you read the getting started with dzVents ?
    ___________________________________________________________________________________________________________________________
    When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
    ___________________________________________________________________________________________________________________________
  • Did you double check the device names used in the script? They need to be exactly equal to the names on your system
  • What do you see in the domoticz log when saving this script as a dzVents event-script
  • What do you see in the log when the text in your status device is set to 'Running'
I added some extra debug lines in below version to force some log lines no matter what the text changes to.

Code: Select all


return
{
    on =
    {
        devices =
        {
            'RoombaS9-State', -- Name of your device
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Roomba',
    },

    execute = function(dz, item)

        dz.log(item.name .. 'is now "' .. item.text .. '"', dz.LOG_DEBUG)

        if item.text == 'Running' then
            dz.devices('Dummy test').switchOn()
        end
    end
}