AC Control (using tasmota IR)

Moderator: leecollings

Post Reply
eddieb
Posts: 340
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

AC Control (using tasmota IR)

Post by eddieb »

Hi,
I wanted to share this code with you all
I use this to send IR commands to my Haier AC using an YTF running tasmota-ir
tnx to waaren for his effort to make this happening
have fun

Eddie

Code: Select all

--[[ Version 20191109

    AC Control
    
        This dz script sends commands to a tasmota enabled IR sender.
        Tested with tasmota 6.7.1-ir version running on YTF
        Tested with Haier AC 

    version
        20191107    Idea from https://www.domoticz.com/wiki/ESPEasy_Aircondition_Inverter_IR_control
                    initial dz version with much help from @waaren
        20191109    added Vertical Swing
                    added comments
    
    Create virtual hardware: Dummy (Does nothing, use for virtual switches only)
    Create virtual sensors (use button on the just created virtual device)
        Types:      Selector    --  for device AC Mode
                    Selector    --  for device AC Fan Speed
                    Selector    --  for device AC Ver Dir
                    SetPoint    --  for device AC Set temperature
                    
                    etc            
]]--
return 
{
    on = { devices = { 'AC*' }},

    logging = { level = domoticz.LOG_DEBUG }, -- change to LOG_ERROR when everything works as expected.

    execute = function(dz, item)
        _G.logMarker =  _G.moduleLabel

        dz.log('Tasmota YTF IR event started for ' .. item.name,dz.LOG_DEBUG)
        dz.log('nValue ' .. item.name ..' ==>> ' .. ( item.nValue or 'nil')  ,dz.LOG_DEBUG)        
        dz.log('sValue ' .. item.name ..' ==>> ' .. ( item.sValue or 'nil') ,dz.LOG_DEBUG)        

        local function sendCommand(settings)
            -- IRhvac {"Vendor":"HAIER_AC_YRW02","Model":-1,"Power":"On","Mode":"Heat","Celsius":"On","Temp":21,"FanSpeed":"Min","SwingV":"Low","SwingH":"Off","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"Off","Filter":"Off","Clean":"Off","Beep":"Off","Sleep":-1}

            local IRSenderIP = 'XXX.XXX.XXX.XXX'     --IP of IRSender !
            
            local url = 'http://' .. IRSenderIP .. '/cm?cmnd=IRhvac%20{' .. 
                        '"Vendor":"HAIER_AC_YRW02",' ..
                        '"Model":-1,' ..
                        '"Power":"' .. settings.power .. '",' .. 
                        '"Mode":"'.. settings.mode.. '",' ..
                        '"Celsius":"On",' ..
                        '"Temp":' .. settings.temperature .. ',' ..
                        '"FanSpeed":"'.. settings.fanSpeed .. '",' .. 
                        '"SwingV":"' .. settings.swingV .. '",' ..
                        '"SwingH":"Off",' ..
                        '"Quiet":"Off",' ..
                        '"Turbo":"Off",' ..
                        '"Econo":"Off",' ..
                        '"Light":"Off",' .. 
                        '"Filter":"Off",' ..
                        '"Clean":"Off",' ..
                        '"Beep":"Off",' ..
                        '"Sleep":-1}'
            dz.openURL(url)
            dz.log(url,dz.LOG_DEBUG)
        end

        local settings = {}
        settings.temperature = dz.utils.round(dz.devices('AC Set Temperature').sValue,1)
        settings.mode = dz.devices('AC Mode').sValue
        settings.fanSpeed = dz.devices('AC Fan Speed').sValue
        settings.swingV = dz.devices('AC Ver Dir').sValue
        settings.power = ( mode == 'Off' and 'Off' ) or 'On'

        sendCommand(settings)
    end
}  
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest