Control Samsung Air Conditioner interfacing Domoticz with SmartThings API  [Solved]

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

Moderator: leecollings

Post Reply
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Control Samsung Air Conditioner interfacing Domoticz with SmartThings API  [Solved]

Post by javalin »

Good night,

I would like any help to 'POST' this command by dzVent to turn off the dispplay of my Air Conditioner. I have write some small lines of code based on a script that I have seen for a washing machine of the same brand, although in that case a GET 'state' is made and my goal is to perform a 'POST' command:

Code: Select all

-- assumpitions for Samsung Air Conditionner Script
-- API key from  https://developer.samsung.com/smartthings
-- Device ID from  https://smartthings.developer.samsung.com/docs/api-ref/st-api.html#operation/getDevices  i used postman to get the device. Making a get requrdy with https://api.smartthings.com/v1/devices/ 

local API = 'Your API token'
local Device = 'Device-ID'
local scriptVar = 'AirConditionner_JSON'

return 
{
    on = 
    {
        timer = 
        {
            'every minute', -- just an example to trigger the request
        },

        httpResponses = 
        {
            scriptVar, -- must match with the callback passed to the openURL command
        },
    },
    
    logging = 
    { 
        level = domoticz.LOG_DEBUG ,
        marker = scriptVar,
    }, 

    execute = function(dz, item)

        if item.isTimer then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                callback = scriptVar, -- httpResponses above.
            })
            return
And the command I want to 'POST' is this:
{
"commands":[
{
"component":"main",
"capability":"execute",
"command":"execute",
"arguments":[
"mode/vs/0",
{
"x.com.samsung.da.options":[
"Light_On"
]
}
]
}
]
}
Any help is appreciated
Last edited by javalin on Sunday 13 December 2020 1:11, edited 4 times in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by waaren »

javalin wrote: Friday 11 December 2020 0:23 I would like any help to 'POST' this command by dzVents to turn off the display of my Air Conditioner.
Any help is appreciated
A first step might be to visit the dzVents wiki and use [CTRL]-f to search on "post". You will get 8 hits; all of them leading to either a description or example code of HTTP calls with method 'POST'
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by wkossen »

I have the same or similar airconditioners. I'm currently working on trying to control it from domoticz. The route i'm choosing for now is to go via Node-Red, where at least i have a working interaction with the airconditioning. Slowly building it up. viewtopic.php?f=28&t=34813 is where i'm currently hoping to get some help. Unfortunately i do not see an option (node) to interact with the display. So i asked the developer of the Node Red plugin here: https://github.com/otaviojr/node-red-co ... /issues/48. There i also posted the api-output of the airco with it's abilities, which i will repeat here, so maybe you can use the name of the ability to control it:

Code: Select all

{
    "items": [
        {
            "deviceId": "_some_ugly_long_id_string_",
            "name": "[room a/c] Samsung",
            "label": "Room air conditioner",
            "manufacturerName": "Samsung Electronics",
            "presentationId": "DA-AC-RAC-000003",
            "deviceManufacturerCode": "Samsung Electronics",
            "locationId": "_some_ugly_long_id_string_",
            "ownerId": "_some_ugly_long_id_string_",
            "roomId": "_some_ugly_long_id_string_",
            "deviceTypeName": "Samsung OCF Air Conditioner",
            "components": [
                {
                    "id": "main",
                    "capabilities": [
                        {
                            "id": "ocf",
                            "version": 1
                        },
                        {
                            "id": "switch",
                            "version": 1
                        },
                        {
                            "id": "airConditionerMode",
                            "version": 1
                        },
                        {
                            "id": "airConditionerFanMode",
                            "version": 1
                        },
                        {
                            "id": "fanOscillationMode",
                            "version": 1
                        },
                        {
                            "id": "temperatureMeasurement",
                            "version": 1
                        },
                        {
                            "id": "thermostatCoolingSetpoint",
                            "version": 1
                        },
                        {
                            "id": "relativeHumidityMeasurement",
                            "version": 1
                        },
                        {
                            "id": "airQualitySensor",
                            "version": 1
                        },
                        {
                            "id": "odorSensor",
                            "version": 1
                        },
                        {
                            "id": "dustSensor",
                            "version": 1
                        },
                        {
                            "id": "veryFineDustSensor",
                            "version": 1
                        },
                        {
                            "id": "audioVolume",
                            "version": 1
                        },
                        {
                            "id": "remoteControlStatus",
                            "version": 1
                        },
                        {
                            "id": "powerConsumptionReport",
                            "version": 1
                        },
                        {
                            "id": "demandResponseLoadControl",
                            "version": 1
                        },
                        {
                            "id": "refresh",
                            "version": 1
                        },
                        {
                            "id": "execute",
                            "version": 1
                        },
                        {
                            "id": "custom.spiMode",
                            "version": 1
                        },
                        {
                            "id": "custom.thermostatSetpointControl",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerOptionalMode",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerTropicalNightMode",
                            "version": 1
                        },
                        {
                            "id": "custom.autoCleaningMode",
                            "version": 1
                        },
                        {
                            "id": "custom.deviceReportStateConfiguration",
                            "version": 1
                        },
                        {
                            "id": "custom.energyType",
                            "version": 1
                        },
                        {
                            "id": "custom.dustFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.veryFineDustFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.deodorFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.electricHepaFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.doNotDisturbMode",
                            "version": 1
                        },
                        {
                            "id": "custom.periodicSensing",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerOdorController",
                            "version": 1
                        },
                        {
                            "id": "custom.ocfResourceVersion",
                            "version": 1
                        },
                        {
                            "id": "custom.disabledCapabilities",
                            "version": 1
                        },
                        {
                            "id": "samsungce.driverVersion",
                            "version": 1
                        }
                    ],
                    "categories": [
                        {
                            "name": "AirConditioner"
                        }
                    ]
                }
            ],
            "profile": {
                "id": "_some_ugly_long_id_string_"
            },
            "type": "OCF",
            "restrictionTier": 0
        }
    ],
    "_links": {}
}

i'm not sure which option it is, maybe the donotdisturb one?

and for the rest, i'll be following this thread. I saw the same washingmachine script and played with it, not getting it going anywhere. i'm no coder. Hopefully we will find ways to get these things working with domoticz better. and hopefully, when we do, someone will help us turn it into a decent plugin. building a plugin has been on my todo/wish list. i tried already without any success. :/

just my 2 cents :)
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by javalin »

waaren wrote: Friday 11 December 2020 7:06
javalin wrote: Friday 11 December 2020 0:23 I would like any help to 'POST' this command by dzVents to turn off the display of my Air Conditioner.
Any help is appreciated
A first step might be to visit the dzVents wiki and use [CTRL]-f to search on "post". You will get 8 hits; all of them leading to either a description or example code of HTTP calls with method 'POST'
Thank you waaren for the advice, I could finish the script :) .
But now I´m blocked again.

Looking to this example, I understand that I can trigger a function by timer OR device

Image

I want always turn off display and, only from 22:00 to 8:00,set to Quiet mode, so I developed this code, but is not working as I supposed:

Code: Select all

-- Assumpitions for Samsung Air Conditionner Script
-- API key from  https://developer.samsung.com/smartthings
-- Device ID from  https://smartthings.developer.samsung.com/docs/api-ref/st-api.html#operation/getDevices  i used postman to get the device. Making a get requrdy with https://api.smartthings.com/v1/devices/ 

local API = 'yyyyyyyyyyyy'
local Device_1 = 'yyyyyyyyyyyy' --Maria
local Device_2 = 'yyyyyyyyyyyy' --Quarto
local scriptVar = 'AC_Light_Off'

  return {
    active = function(domoticz)            -- This function will be evaluated every minute by the dzVents system
        myScript = domoticz.devices(592)   -- This command checks the status of the switch to keep the script active
        return myScript.state == "Off"
    end,
    on = 
    {
        devices = {
            AC_Quarto,AC_Maria,
        },
        timer = 
        {
            'at 16:30-18:20', -- just an example to trigger the request
        },
        httpResponses = 
        {
            scriptVar, -- must match with the callback passed to the openURL command
        },
    },
    
    logging = 
    { 
        level = domoticz.LOG_DEBUG , -- set to LOG_ERROR when script works as expected or LOG_DEBUG for debugging
        marker = scriptVar,
    }, 

    execute = function(dz, item)
local AC_Quarto = dz.devices(14) --590
local AC_Maria = dz.devices(589)
        if (item.isTimer and AC_Maria.active) then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
--              https://community.home-assistant.io/t/samsung-air-conditioner/87046/55
                postData = '{"commands":[{"component":"main","capability":"custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}'
--              postData = '{"commands":[{"component":"main","capability":"switch","command":"on","arguments":[]}]}'
--              postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })
    

        elseif (AC_Quarto.isDevice and AC_Quarto.active) then
            
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })            
       
         elseif (item.isTimer and AC_Quarto.active) then
            
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })   
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
--              https://community.home-assistant.io/t/samsung-air-conditioner/87046/55
                postData = '{"commands":[{"component":"main","capability":"custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}'
            }) 

        else 
            if (AC_Maria.active) then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
             })
            elseif (AC_Quarto.active) then
            
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })            
            end

        end

    end
}
Attachments
Capturar.JPG
Capturar.JPG (49.47 KiB) Viewed 4844 times
Last edited by javalin on Friday 11 December 2020 18:44, edited 1 time in total.
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by javalin »

wkossen wrote: Friday 11 December 2020 10:09 I have the same or similar airconditioners. I'm currently working on trying to control it from domoticz. The route i'm choosing for now is to go via Node-Red, where at least i have a working interaction with the airconditioning. Slowly building it up. viewtopic.php?f=28&t=34813 is where i'm currently hoping to get some help. Unfortunately i do not see an option (node) to interact with the display. So i asked the developer of the Node Red plugin here: https://github.com/otaviojr/node-red-co ... /issues/48. There i also posted the api-output of the airco with it's abilities, which i will repeat here, so maybe you can use the name of the ability to control it:

Code: Select all

{
    "items": [
        {
            "deviceId": "_some_ugly_long_id_string_",
            "name": "[room a/c] Samsung",
            "label": "Room air conditioner",
            "manufacturerName": "Samsung Electronics",
            "presentationId": "DA-AC-RAC-000003",
            "deviceManufacturerCode": "Samsung Electronics",
            "locationId": "_some_ugly_long_id_string_",
            "ownerId": "_some_ugly_long_id_string_",
            "roomId": "_some_ugly_long_id_string_",
            "deviceTypeName": "Samsung OCF Air Conditioner",
            "components": [
                {
                    "id": "main",
                    "capabilities": [
                        {
                            "id": "ocf",
                            "version": 1
                        },
                        {
                            "id": "switch",
                            "version": 1
                        },
                        {
                            "id": "airConditionerMode",
                            "version": 1
                        },
                        {
                            "id": "airConditionerFanMode",
                            "version": 1
                        },
                        {
                            "id": "fanOscillationMode",
                            "version": 1
                        },
                        {
                            "id": "temperatureMeasurement",
                            "version": 1
                        },
                        {
                            "id": "thermostatCoolingSetpoint",
                            "version": 1
                        },
                        {
                            "id": "relativeHumidityMeasurement",
                            "version": 1
                        },
                        {
                            "id": "airQualitySensor",
                            "version": 1
                        },
                        {
                            "id": "odorSensor",
                            "version": 1
                        },
                        {
                            "id": "dustSensor",
                            "version": 1
                        },
                        {
                            "id": "veryFineDustSensor",
                            "version": 1
                        },
                        {
                            "id": "audioVolume",
                            "version": 1
                        },
                        {
                            "id": "remoteControlStatus",
                            "version": 1
                        },
                        {
                            "id": "powerConsumptionReport",
                            "version": 1
                        },
                        {
                            "id": "demandResponseLoadControl",
                            "version": 1
                        },
                        {
                            "id": "refresh",
                            "version": 1
                        },
                        {
                            "id": "execute",
                            "version": 1
                        },
                        {
                            "id": "custom.spiMode",
                            "version": 1
                        },
                        {
                            "id": "custom.thermostatSetpointControl",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerOptionalMode",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerTropicalNightMode",
                            "version": 1
                        },
                        {
                            "id": "custom.autoCleaningMode",
                            "version": 1
                        },
                        {
                            "id": "custom.deviceReportStateConfiguration",
                            "version": 1
                        },
                        {
                            "id": "custom.energyType",
                            "version": 1
                        },
                        {
                            "id": "custom.dustFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.veryFineDustFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.deodorFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.electricHepaFilter",
                            "version": 1
                        },
                        {
                            "id": "custom.doNotDisturbMode",
                            "version": 1
                        },
                        {
                            "id": "custom.periodicSensing",
                            "version": 1
                        },
                        {
                            "id": "custom.airConditionerOdorController",
                            "version": 1
                        },
                        {
                            "id": "custom.ocfResourceVersion",
                            "version": 1
                        },
                        {
                            "id": "custom.disabledCapabilities",
                            "version": 1
                        },
                        {
                            "id": "samsungce.driverVersion",
                            "version": 1
                        }
                    ],
                    "categories": [
                        {
                            "name": "AirConditioner"
                        }
                    ]
                }
            ],
            "profile": {
                "id": "_some_ugly_long_id_string_"
            },
            "type": "OCF",
            "restrictionTier": 0
        }
    ],
    "_links": {}
}

i'm not sure which option it is, maybe the donotdisturb one?

and for the rest, i'll be following this thread. I saw the same washingmachine script and played with it, not getting it going anywhere. i'm no coder. Hopefully we will find ways to get these things working with domoticz better. and hopefully, when we do, someone will help us turn it into a decent plugin. building a plugin has been on my todo/wish list. i tried already without any success. :/

just my 2 cents :)
Thank you for sharing :)
I have also used the smartthings module from node red but it could only switch on and off my air conditionner. The news AC´s works with OCF protocol and that is why the rest of the options do not work in node red. Now we can control almost all the functionalities of ours machines from domoticz without node red. :)

I have made the scrip dzvents, it is working from domoticz and for now you can choose Quiet, Switch On or turnoff display. A have not yer the final version but you can see:

Code: Select all

-- Assumpitions for Samsung Air Conditionner Script
-- API key from  https://developer.samsung.com/smartthings
-- Device ID from  https://smartthings.developer.samsung.com/docs/api-ref/st-api.html#operation/getDevices  i used postman to get the device. Making a get requrdy with https://api.smartthings.com/v1/devices/ 

local API = 'yyyyyyyyy'
local Device_1 = 'yyyyyyyyy' --Maria
local Device_2 = 'yyyyyyyyy' --Quarto
local scriptVar = 'AC_Light_Off'

  return {
    active = function(domoticz)            -- This function will be evaluated every minute by the dzVents system
        myScript = domoticz.devices(592)   -- This command checks the status of the switch to keep the script active
        return myScript.state == "Off"
    end,
    on = 
    {
        devices = {
            'AC Maria','AC Quarto',
        },
        timer = 
        {
            'every minute', -- just an example to trigger the request
        },
        httpResponses = 
        {
            scriptVar, -- must match with the callback passed to the openURL command
        },
    },
    
    logging = 
    { 
        level = domoticz.LOG_ERROR , -- set to LOG_ERROR when script works as expected or LOG_DEBUG for debugging
        marker = scriptVar,
    }, 

    execute = function(dz, item)

        if item.isTimer then
        elseif (item.isDevice and item.name == 'AC Maria' and item.active) then
            
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })
        elseif (item.isDevice and item.name == 'AC Quarto' and item.active) then
            
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
            })            
         
        end
    end
}
Quiet mode, Switch on, Turn off display commands:

Code: Select all

  
postData = '{"commands":[{"component":"main","capability":"custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}'
postData = '{"commands":[{"component":"main","capability":"switch","command":"on","arguments":[]}]}'
postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}
[/quote]
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by waaren »

javalin wrote: Friday 11 December 2020 17:40 But now I´m blocked again.
I want always turn off display and, only from 22:00 to 8:00,set to Quiet mode, so I developed this code, but is not working as I supposed:
Can you please explain?
Does the script have to run every minute or only on a device update or both?
If you want to check a time hen it is easier to use something like

Code: Select all

if dz.time.matchesRule('at 22:00-08:00') then
in the execute body of the script.

Code: Select all

elseif (AC_Quarto.isDevice and AC_Quarto.active) then
Should probably be

Code: Select all

elseif item.isDevice and AC_Quarto.active then
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by wkossen »

Nice work. I love to bring this further. Good to know that node-red cant do everything. I'm very bad at scripting, so i love to use what others did already and adapt it where necessary for me. So a few questions to get me going :)

what type of device is AC Maria within domoticz? Some dummy switch?
How would i then use that to turn it off and on in the script?
And how would i tell it to heat or cool and what temp to set?

and thats for posting commands. how do i poll data from it, like temp and humidity? It's pretty usefull that the machine is also a sensor, so i could build a thermostat with domoticz to control the climate in the room automagically :). These samsung commands are pretty involved to grasp....

Would it be an idea to create a set of scripts to do all the things necessary and release those on github? I'ld love to beta test them...
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by javalin »

Can you please explain?
Does the script have to run every minute or only on a device update or both?
Only on a device update
If you want to check a time hen it is easier to use something like

Code: Select all

if dz.time.matchesRule('at 22:00-08:00') then
in the execute body of the script.
Thank you very much. Now it is working!

Code: Select all

elseif (AC_Quarto.isDevice and AC_Quarto.active) then
Should probably be

Code: Select all

elseif item.isDevice and AC_Quarto.active then
You are right

This is the code that is working, is there any way to make them more organized?

Code: Select all

-- Assumpitions for Samsung Air Conditionner Script
-- API key from  https://developer.samsung.com/smartthings
-- Device ID from  https://smartthings.developer.samsung.com/docs/api-ref/st-api.html#operation/getDevices  i used postman to get the device. Making a get requrdy with https://api.smartthings.com/v1/devices/ 
-- With method = 'POST' to work with the following commands:
--
--(Switch on):  postData = '{"commands":[{"component":"main","capability":"switch","command":"on","arguments":[]}]}'
--(Switch off): postData = '{"commands":[{"component":"main","capability":"switch","command":"off","arguments":[]}]}'
--(Display off):postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
--(Heat):       postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}'
--(Cool):       postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Cool"]}]}]}'
--(Setpoint):   postData = '{"commands":[{"component":"main","capability":"thermostatCoolingSetpoint","command":"setCoolingSetpoint","arguments":[26]}]}'
--(Quiet):      postData = '{"commands":[{"component":"main","capability":"custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}'

-- With method = 'GET' the following url's:
--
--(Room Temp):  url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/temperatureMeasurement/status'
--(Humidity):   url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/relativeHumidityMeasurement/status'
--(Consumption):url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/powerConsumptionReport/status'

--  https://community.home-assistant.io/t/samsung-air-conditioner/87046/55

local API = 'yyyyy'
local Device_1 = 'yyyyy' --Maria
local scriptVar = 'AC_Light_Off'

  return {
    active = function(domoticz)            -- This function will be evaluated every minute by the dzVents system
        myScript = domoticz.devices(592)   -- This command checks the status of the switch to keep the script active
        return myScript.state == "Off"
    end,
    on = 
    {
        devices = {
            AC_Maria,'AC Maria',
        },

        httpResponses = 
        {
            scriptVar, -- must match with the callback passed to the openURL command
        },
    },
    
    logging = 
    { 
        level = domoticz.LOG_DEBUG , -- set to LOG_ERROR when script works as expected or LOG_DEBUG for debugging
        marker = scriptVar,
    }, 

    execute = function(dz, item)
    
         local AC_Maria = dz.devices(589)
         if dz.time.matchesRule('at 23:00-08:00') and AC_Maria.active then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                --callback = scriptVar, -- httpResponses above.
                postData = '{"commands":[{"component":"main","capability":"switch","command":"on","arguments":[]}]}'
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}'
             })
             dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":"thermostatCoolingSetpoint","command":"setCoolingSetpoint","arguments":[24]}]}'
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}' 
                
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":"custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}'
            })
    
         elseif item.isDevice and  AC_Maria.active then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":"switch","command":"on","arguments":[]}]}'
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}'
             })
             dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":"thermostatCoolingSetpoint","command":"setCoolingSetpoint","arguments":[22]}]}'
             })
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{ "commands":[{"component":"main","capability":"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}'   
             })

         elseif item.isDevice and  AC_Maria.state == 'Off' then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":"switch","command":"off","arguments":[]}]}' 
             })
         end
    end
}
}
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by javalin »

wkossen wrote: Saturday 12 December 2020 12:48 what type of device is AC Maria within domoticz? Some dummy switch?
yes!
How would i then use that to turn it off and on in the script?
And how would i tell it to heat or cool and what temp to set?
I just posted the script, you can check the code. You can also get the room temp and humidity, check the notes. I also leave a link with more info
It's pretty usefull that the machine is also a sensor, so i could build a thermostat with domoticz to control the climate in the room automagically :)
You can use Smart Virtual Thermostat pluging for Domoticz, works wonderful :mrgreen:
Would it be an idea to create a set of scripts to do all the things necessary and release those on github? I'ld love to beta test them...
I am not a code developer, I only read the wiki and consult the forum, but I agree with you. It would be great to have a plugin for domoticz. :idea:
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Turn off light Samsung Windfree Air Conditioner

Post by waaren »

javalin wrote: Sunday 13 December 2020 0:49 is there any way to make them more organized?
Could be something like

Code: Select all

--[[
        Assumptions for Samsung Air Conditionner Script

        API key from  https://developer.samsung.com/smartthings

        I used postman to get the device. https://api.smartthings.com/v1/devices/

         Device ID from  https://smartthings.developer.samsung.com/docs/api-ref/st-api.html#operation/getDevices
         With method = 'POST' to work with the following commands:

        postData = '{"commands":[{"component":"main","capability:"

        (Switch on) :  "switch","command":"on","arguments":[]}]}
        (Switch off):  "switch","command":"off","arguments":[]}]}
        (Display off): "execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}
        (Heat):        "execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}
        (Cool):        "execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Cool"]}]}]}
        (Setpoint):    "thermostatCoolingSetpoint","command":"setCoolingSetpoint","arguments":[26]}]}
        (Quiet):       "custom.airConditionerOptionalMode","command":"setAcOptionalMode","arguments":["quiet"]}]}

        With method = 'GET' the following url's:

        (Room Temp):  url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/temperatureMeasurement/status'
        (Humidity):   url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/relativeHumidityMeasurement/status'
        (Consumption):url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/components/main/capabilities/powerConsumptionReport/status'

        https://community.home-assistant.io/t/samsung-air-conditioner/87046/55
]]--

local API = 'yyyyy'
local Device_1 = 'yyyyy' --Maria virtual switch
local scriptVar = 'AC_Light_Off'
local activeDevice = 592

return
{
    on =
    {
        devices =
        {
            'AC_Maria', 'AC Maria', -- Are these the same?
        },

        httpResponses = -- Not used in this script. Should it stay in?
        {
            scriptVar,
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG , -- set to LOG_ERROR when script works as expected or LOG_DEBUG for debugging
        marker = scriptVar,
    },

    execute = function(dz, item)
        if not(dz.devices(activeDevice).active) then return end -- No need to run now (this is more efficient than do the check in the active section)

        local AC_Maria = dz.devices(589)

        local controls = -- control table
        {
            {
                time = true, active = true, -- conditions
                post =                    -- table with postdata strings
                {
                    '"switch","command":"on","arguments":[]}]}' ,
                    '"execute", "command":"execute", "arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}',
                    '"thermostatCoolingSetpoint", "command":"setCoolingSetpoint","arguments":[24]}]}',
                    '"execute", "command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}',
                    '"custom.airConditionerOptionalMode", "command":"setAcOptionalMode","arguments":["quiet"]}]}',
                },
            },

            {
                device = true, active = true,
                post =
                {
                    '"switch","command":"on","arguments":[]}]}' ,
                    '"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}',
                    '"thermostatCoolingSetpoint", "command":"setCoolingSetpoint","arguments":[22]}]}',
                    '"execute","command":"execute", "arguments":["mode/vs/0",{"x.com.samsung.da.options":["Light_On"]}]}]}',
                },
            },

            {
                device = true, active = false,
                post =
                {
                    '"switch","command":"off","arguments":[]}]}',
                },
            },
        }

        local function post(postData)
            dz.openURL(
            {
                url = 'https://api.smartthings.com/v1/devices/'.. Device_1 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":'  .. postData,
            })
        end

        local function walkConditions(type, active)
            for _, control in ipairs(controls) do
                if control[type] and control.active == active then
                    for _, postData in ipairs(control.post) do
                        post(postData)
                    end
                end
            end
        end

        -- Main
        if dz.time.matchesRule('at 23:00-08:00') and AC_Maria.active then
            walkConditions('time', true)
        elseif item.isDevice and AC_Maria.active then
            walkConditions('device', true)
        elseif item.isDevice and  AC_Maria.state == 'Off' then
            walkConditions('device', false)
        end
    end
}


Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by javalin »

Thank you very much waaren, your code is much better developed. I have some doubt with the loop that you have created for the calls to the 'post' function:

Code: Select all

local function walkConditions(type, active)
            for _, control in ipairs(controls) do
                if control[type] and control.active == active then
                    for _, postData in ipairs(control.post) do
                        post(postData)
                    end
                end
            end
        end
Why do we use brackets with 'type' and dots with the 'active' and 'post'? control[type], control.active, control.post. 'Type' is a key table?

Code: Select all

execute = function(dz, item)
        if not(dz.devices(activeDevice).active) then return end -- No need to run now (this is more efficient than do the check in the active section)
It is more efficient because is only checked if we trigger the function, and not every minute?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by waaren »

javalin wrote: Sunday 13 December 2020 16:55 I have some doubt with the loop that you have created for the calls to the 'post' function:
Why do we use brackets with 'type' and dots with the 'active' and 'post'? control[type], control.active, control.post. 'Type' is a key table?
type is a variable key in the table and control.active is a string key You can rewrite control.active as control['active'] if you prefer that syntax; For Lua it is the same. My preference is control.active

Code: Select all

execute = function(dz, item)
        if not(dz.devices(activeDevice).active) then return end -- No need to run now (this is more efficient than do the check in the active section)
It is more efficient because is only checked if we trigger the function, and not every minute?
Even worse. The active function is checked every minute and on every device change in the system.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by javalin »

waaren the scripts are working wonderfully, yesterday I modified the code to make a small heat boost between 5-00 and 6:00am by modifying this line:

Code: Select all

        if dz.time.matchesRule('at 22:30-08:00 except at 5:00-6:00') and AC_Maria.active then
            walkConditions('time', true)
It has not worked, from what I understand, we can not use 'exepctions' witch matchesRule. I should create something similar to this, right?

Code: Select all

        if dz.time.matchesRule('at 22:30-05:00') and AC_Maria.active then
            walkConditions('time', true)
        elseif if dz.time.matchesRule('at 06:00-08:00') and AC_Maria.active then
           walkConditions('time', true)
        elseif item.isDevice and AC_Maria.active then
            walkConditions('device', true)
        elseif item.isDevice and  AC_Maria.state == 'Off' then
            walkConditions('device', false)
        end 
Kind regards and thank you
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by waaren »

javalin wrote: Thursday 17 December 2020 10:45 From what I understand, we can not use 'except' witch matchesRule.
except does work in the timer section and in dz.time.matchesRule() -- in dzVents version >= 3.0.16
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by javalin »

except does work in the timer section and in dz.time.matchesRule() -- in dzVents version >= 3.0.16
Ok, thank you for the explanation. My dzVents version is 3.0.2, may I update only this file to get in work?

https://github.com/domoticz/domoticz/bl ... e/Time.lua
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by waaren »

javalin wrote: Thursday 17 December 2020 13:20
except does work in the timer section and in dz.time.matchesRule() -- in dzVents version >= 3.0.16
Ok, thank you for the explanation. My dzVents version is 3.0.2, may I update only this file to get in work?

https://github.com/domoticz/domoticz/bl ... e/Time.lua
No
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by javalin »

This is my last update, I have included code to get temperatute, humidity, energy consumption and status form AC. It is possible to update the satutus even if the IR remote controller is used. I have used the silent() function to do that. Very usefull. I get this status every 3 minutes, but now the script POST the commands (on, heat, setpoint,etc...) also every 3 minutes, I think is because the callback. I could split the code in two scripts, one to contol and another to get the status, but i would like to now if I can do something to keep in one script.

Code: Select all

local API = 'yyyyy'
local Device_2 = 'yyyyy' --Quarto
local scriptVar = 'AC_control SmartThings API'
local activeDevice = 592

return
{
    on =
    {
        timer = 
        {
            'every 3 minutes',
        },
    
        devices =
        {
            'AC Quarto', --execute function is executed at each change of state or value 
        },
    
        httpResponses = 
        {
            scriptVar, -- must match with the callback passed to the openURL command
        },    
    },

    logging =
    {
        level = domoticz.LOG_ERROR , -- set to LOG_ERROR when script works as expected or LOG_DEBUG for debugging
        marker = scriptVar,
    },

    execute = function(dz, item)
        if not(dz.devices(activeDevice).active) then return end -- No need to run now (this is more efficient than do the check in the active section)
        local AC_room = dz.devices(590)
        local AC_counter = dz.devices(628) 
        local AC_temp = dz.devices(630) 
        local controls = -- control table
        {
            {
                time = true, active = true, -- conditions
                post =                    -- table with postdata strings
                {
                    '"switch","command":"on","arguments":[]}]}' ,
                    '"execute", "command":"execute", "arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}',
                    '"thermostatCoolingSetpoint", "command":"setCoolingSetpoint","arguments":[24]}]}',
                    '"execute", "command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.options":["Light_On"]}]}]}',
                    '"custom.airConditionerOptionalMode", "command":"setAcOptionalMode","arguments":["quiet"]}]}',
                },
            },

            {
                device = true, active = true,
                post =
                {
                    '"switch","command":"on","arguments":[]}]}' ,
                    '"execute","command":"execute","arguments":["mode/vs/0", {"x.com.samsung.da.modes":["Heat"]}]}]}',
                    '"thermostatCoolingSetpoint", "command":"setCoolingSetpoint","arguments":[22]}]}',
                    '"execute","command":"execute", "arguments":["mode/vs/0",{"x.com.samsung.da.options":["Light_On"]}]}]}',
                    '"airConditionerFanMode","command":"setFanMode","arguments":["low"]}]}',
                },
            },

            {
                device = true, active = false,
                post =
                {
                    '"switch","command":"off","arguments":[]}]}',
                },
            },
        }

        local function post(postData)
            dz.openURL(
            {
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/commands',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'POST',
                postData = '{"commands":[{"component":"main","capability":'  .. postData,
            })
        end

        local function walkConditions(type, active)
            for _, control in ipairs(controls) do  
                if control[type] and control.active == active then --type is a variable key in the table and control.active is a string key 
                    for _, postData in ipairs(control.post) do       
                        post(postData)                               
                    end
                end
            end
        end

        -- Main control
        if dz.time.matchesRule('at 22:30-05:00') and AC_room.active then
            --'at 22:30-08:00'
            walkConditions('time', true)
        elseif dz.time.matchesRule('at 06:00-08:00') and AC_room.active then
           walkConditions('time', true)
        elseif item.isDevice and AC_room.active then
            walkConditions('device', true)
        elseif item.isDevice and  AC_room.state == 'Off' then
            walkConditions('device', false)
        end
        -- Send status to domoticz
        if (item.isTimer) then
            dz.openURL({
                url = 'https://api.smartthings.com/v1/devices/'.. Device_2 .. '/components/main/status',
                headers = { ['Authorization'] = 'Bearer '.. API },
                method = 'GET',
                callback = scriptVar, -- httpResponses above.
            })
            return
        end
        if (item.isHTTPResponse) then
	    if (item.statusCode == 200) then
                if (item.isJSON) then -- when recognized as json then dzVents will convert it to a table for you
                    rt = item.json
                    local power = rt.powerConsumptionReport.powerConsumption["value"]["power"] 
                    local energy = rt.powerConsumptionReport.powerConsumption["value"]["energy"]
                    local temp = rt.temperatureMeasurement.temperature["value"]
                    local hum = rt.relativeHumidityMeasurement.humidity["value"]
                    local switch = rt.switch.switch["value"]
                    AC_counter.updateElectricity(power, energy)          -- store new value in kW,kWh to electric counter
                    AC_temp.updateTempHum(temp,hum)
                        if switch == 'on' then
                            AC_room.switchOn().checkFirst().silent() -- It switches to the on-state but doesn't execute any other scripts.
                        elseif switch == 'off' then
                            AC_room.switchOff().checkFirst().silent() 
                        end
                    dz.log('\n-\nAnd now The Device INFO of your API \n-\n ', dz.LOG_DEBUG) 
                    dz.log(power,dz.LOG_DEBUG)
                    dz.log(energy,dz.LOG_DEBUG)
                    dz.log(switch,dz.LOG_DEBUG)
                end
            end
        end
    end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by waaren »

javalin wrote: Monday 21 December 2020 9:01 This is my last update, I have included code to get temperatute, humidity, energy consumption and status form AC. It is possible to update the satutus even if the IR remote controller is used. I have used the silent() function to do that. Very usefull. I get this status every 3 minutes, but now the script POST the commands (on, heat, setpoint,etc...) also every 3 minutes, I think is because the callback. I could split the code in two scripts, one to contol and another to get the status, but i would like to now if I can do something to keep in one script.
If you want this only to happen when the script is triggered by a time- or a device-trigger then change the function walkConditions to

Code: Select all

        local function walkConditions(type, active)
            if item.isTimer or item.isDevice then
                for _, control in ipairs(controls) do  
                    if control[type] and control.active == active then --type is a variable key in the table and control.active is a string key 
                        for _, postData in ipairs(control.post) do       
                            post(postData)                               
                        end
                    end
                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
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Control Samsung Air Conditioner interfacing Domoticz with SmartThings API

Post by javalin »

I want walkConditions triggered only by device state and get the temperature or device switch status every 3 minutes
If I include item.isTimer in walkConditions, function will execute also every 3 minutes. May be just enough with item.isDevice.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest