Changing remote  [Solved]

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

Moderator: leecollings

Post Reply
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Changing remote

Post by jkimmel »

Some time ago with the help of dannybloe I created this script

Code: Select all

local masterSlave = {
   ['zza FB 11 Stehlampen Salon'] = 'FB 11 Stehlampen Salon',
   ['zza FB 12 Downlight Kamin'] = 'FB 12 Downlight Kamin',
   ['zza FB 13 Downlight Terrasse'] = 'FB 13 Downlight Terrasse',
   ['zza FB 14 Lampe Esstisch'] = 'FB 14 Lampe Esstisch',
   ['zza FB 21 Heizkreis Salon'] = 'FB 21 Heizkreis Salon',
   ['zza FB 23 Heizkreis Buero'] = 'FB 23 Heizkreis Buero',
   ['zza FB 31 Infrarot'] = 'FB 31 Infrarot',
   ['zza FB 32 Heizkreis Schlafzimmer'] = 'FB 32 Heizkreis Schlafzimmer',
   ['zza FB 33 Waermepumpe'] = 'FB 33 Waermepumpe',
   ['zza FB 41 Heizkreis Gaestebad'] = 'FB 41 Heizkreis Gaestebad',
   ['zza FB 42 Heizkreis Bad'] = 'FB 42 Heizkreis Bad',
   ['zza FB 43 Downlight Tresen'] = 'FB 43 Downlight Tresen',
   ['zza FB 44 Stehlampe Buero'] = 'FB 44 Stehlampe Buero'
}

return {
   active = true,
   on = {
            'zza FB *' -- you use prefix method here so no need to list them all individually, use the wildcard.
   },
   execute = function(domoticz, masterSwitch)

      -- get the slave device using the lookup table above
      -- but do some checking first to catch misstakes

      if (masterSlave[masterSwitch.name] == nil) then
         -- oops
         domoticz.log(masterSwitch.name .. ' cannot be found in the lookup table. Check the names.', domoticz.LOG_ERROR)
      end
      
      -- now get the slave device and check if it exists
      local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
      
      if (slaveSwitch == nil) then
         -- oops again
         domoticz.log('There is no slave device by the name ' .. masterSlave[masterSwitch.name] .. '. Check the names', domoticz.LOG_ERROR)
      else
      
         -- we're good to go.. we have a slave device 
         if (masterSwitch.state == 'On') then
            slaveSwitch.switchOn()
         else
            slaveSwitch.switchOff()
         end
      end
   end 
}
Unfortunetly it isn't working anymore
The slave is not switching.
Rfxcom
Raspi 4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Changing remote

Post by waaren »

jkimmel wrote: Sunday 27 October 2019 19:14 Some time ago with the help of dannybloe I created this script

Code: Select all

      -- now get the slave device and check if it exists
      local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
Unfortunetly it isn't working anymore. The slave is not switching.
You must have been using quite an old version... The usage of square brackets for domoticz.devices is no longer usable from dzVents 2.0

Please try again after changing the line

Code: Select all

local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
to

Code: Select all

local slaveSwitch = domoticz.devices(masterSlave[masterSwitch.name])

Please include some text what is expected and what goes wrong when you report a problem including any relevant loglines next time. That will make it easier to help you.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Changing remote

Post by jkimmel »

first thank you for your help.
The reason of this script:
My Remote was broke so the new remote - switching zza * switches - had to be arranged to replace the old one.
So p. e. zza FB 21 should switch FB 21
Even with the change you suggested the master switch is not switching yet.
Rfxcom
Raspi 4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Changing remote

Post by waaren »

jkimmel wrote: Tuesday 29 October 2019 16:36 Even with the change you suggested the master switch is not switching yet.
Can you try this one ?
And if still not working then please include some text what goes wrong and include any relevant loglines. That will make it easier to help you.

Code: Select all

return 
{
    on = { devices = { 'zza FB*' }},
   
    logging = { level = domoticz.LOG_DEBUG },

    execute = function(domoticz, masterSwitch)

        _G.logMarker = _G.moduleLabel -- Set marker to scriptname

        local masterSlave = 
        {
           ['zza FB 11 Stehlampen Salon'] = 'FB 11 Stehlampen Salon',
           ['zza FB 12 Downlight Kamin'] = 'FB 12 Downlight Kamin',
           ['zza FB 13 Downlight Terrasse'] = 'FB 13 Downlight Terrasse',
           ['zza FB 14 Lampe Esstisch'] = 'FB 14 Lampe Esstisch',
           ['zza FB 21 Heizkreis Salon'] = 'FB 21 Heizkreis Salon',
           ['zza FB 23 Heizkreis Buero'] = 'FB 23 Heizkreis Buero',
           ['zza FB 31 Infrarot'] = 'FB 31 Infrarot',
           ['zza FB 32 Heizkreis Schlafzimmer'] = 'FB 32 Heizkreis Schlafzimmer',
           ['zza FB 33 Waermepumpe'] = 'FB 33 Waermepumpe',
           ['zza FB 41 Heizkreis Gaestebad'] = 'FB 41 Heizkreis Gaestebad',
           ['zza FB 42 Heizkreis Bad'] = 'FB 42 Heizkreis Bad',
           ['zza FB 43 Downlight Tresen'] = 'FB 43 Downlight Tresen',
           ['zza FB 44 Stehlampe Buero'] = 'FB 44 Stehlampe Buero',
        }

          -- get the slave device using the lookup table above
          -- but do some checking first to catch misstakes

        if masterSlave[masterSwitch.name] == nil then
             -- oops
             domoticz.log(masterSwitch.name .. ' cannot be found in the lookup table. Check the names.', domoticz.LOG_ERROR)
             return
        end
        -- now get the slave device and check if it exists
        local slaveSwitch = domoticz.devices(masterSlave[masterSwitch.name])
          
        if slaveSwitch == nil then
             -- oops again
             domoticz.log('There is no slave device by the name ' .. masterSlave[masterSwitch.name] .. '. Check the names', domoticz.LOG_ERROR)
            return
        else
            -- we're good to go.. we have a slave device 
            if (masterSwitch.state == 'On') then
                slaveSwitch.switchOn()
            else
                slaveSwitch.switchOff()
            end
        end
    end 
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Changing remote

Post by jkimmel »

Wow, it's working now.
Tx
Rfxcom
Raspi 4
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Changing remote

Post by jkimmel »

Sorry, it's not working in one aspect which I didn't test earlier.
when pushing the remote button assigned to "zza FB 12" the script runs endless without any pause.
I have to disable DzVents and enable again to stop this.
I can't see any difference to other switches which are working.
Rfxcom
Raspi 4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Changing remote

Post by waaren »

jkimmel wrote: Thursday 07 November 2019 12:44 Sorry, it's not working in one aspect which I didn't test earlier.
when pushing the remote button assigned to "zza FB 12" the script runs endless without any pause.
I have to disable DzVents and enable again to stop this.
I can't see any difference to other switches which are working.
Sounds like the slave device somehow triggers the master device. Could be a number of things
  • another script
  • something defined in the on- or off Action area of the slave device
  • something defined in the sub/slave area of the slave device
I added a dump() statement to below script to get some information on the slave device and add the option silent() to the switch commands. The option silent() does prevent any subsequent (script) events to be triggered.

Please try with this onw and collect all relevant loglines. The dump() command produce > 100 lines so to capture all you will have to log to an OS file or start domoticz from the CLI with

Code: Select all

cd <domoticz dir>  
sudo ./domoticz 

Code: Select all

return 
{
    on = { devices = { 'zza FB*' }},
   
    logging = { level = domoticz.LOG_DEBUG },

    execute = function(domoticz, masterSwitch)

        _G.logMarker = _G.moduleLabel -- Set marker to scriptname

        local masterSlave = 
        {
           ['zza FB 11 Stehlampen Salon'] = 'FB 11 Stehlampen Salon',
           ['zza FB 12 Downlight Kamin'] = 'FB 12 Downlight Kamin',
           ['zza FB 13 Downlight Terrasse'] = 'FB 13 Downlight Terrasse',
           ['zza FB 14 Lampe Esstisch'] = 'FB 14 Lampe Esstisch',
           ['zza FB 21 Heizkreis Salon'] = 'FB 21 Heizkreis Salon',
           ['zza FB 23 Heizkreis Buero'] = 'FB 23 Heizkreis Buero',
           ['zza FB 31 Infrarot'] = 'FB 31 Infrarot',
           ['zza FB 32 Heizkreis Schlafzimmer'] = 'FB 32 Heizkreis Schlafzimmer',
           ['zza FB 33 Waermepumpe'] = 'FB 33 Waermepumpe',
           ['zza FB 41 Heizkreis Gaestebad'] = 'FB 41 Heizkreis Gaestebad',
           ['zza FB 42 Heizkreis Bad'] = 'FB 42 Heizkreis Bad',
           ['zza FB 43 Downlight Tresen'] = 'FB 43 Downlight Tresen',
           ['zza FB 44 Stehlampe Buero'] = 'FB 44 Stehlampe Buero',
        }

          -- get the slave device using the lookup table above
          -- but do some checking first to catch misstakes

        if masterSlave[masterSwitch.name] == nil then
             -- oops
             domoticz.log(masterSwitch.name .. ' cannot be found in the lookup table. Check the names.', domoticz.LOG_ERROR)
             return
        end
        -- now get the slave device and check if it exists
        local slaveSwitch = domoticz.devices(masterSlave[masterSwitch.name])
        
        if slaveSwitch == nil then
             -- oops again
             domoticz.log('There is no slave device by the name ' .. masterSlave[masterSwitch.name] .. '. Check the names', domoticz.LOG_ERROR)
            return
        else
            if masterSwitch.name = 'zza FB 12 Downlight Kamin' then
                slaveSwitch.dump()
            end
  

            -- we're good to go.. we have a slave device 
            if (masterSwitch.state == 'On') then
                slaveSwitch.switchOn().silent()
            else
                slaveSwitch.switchOff().silent()
            end
        end
    end 
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Changing remote [Solved]  [Solved]

Post by jkimmel »

Thank you.
Your hints already solved it.
it was about the slave area.
Rfxcom
Raspi 4
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest