Events from Xiaiomi devices

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

Moderator: leecollings

Post Reply
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Events from Xiaiomi devices

Post by ulfh2018 »

I have just started trying a Xiomi Gateway, and the only device I have been testing so far is a temperature / humidity sensor. This seems to work, though it looks like the reading are sometimes missing for shorter or longer periods.

I want to be able to send information using MQTT, which means I have to get information from for example:
IDX Hardware ID Unit Name Type Sub Type Value
10 Xiaomi AD55 85 Temperatur Ute Temp LaCrosse TX3 16.9 C
9 Dummy 0014059 1 Termostat Ute Thermostat SetPoint 16.5

The second entry is for a thermostat setting, and I pick up information using dzVents like this;

Code: Select all

return {
    on = {       timer = { 'every minute'  } },
  
    execute = function(domoticz)
        local Sensor    = domoticz.devices(10)  -- Temperature
        local SETPOINT  = domoticz.devices(9) -- SetPoint
        SETPOINT.updateSetPoint(SETPOINT.setPoint)  -- This will refresh the setPoint with current value
        if (Sensor.temperature <= (SETPOINT.setPoint - 0.2)) then -- turn on heat
            domoticz.devices(14).switchOn().checkFirst()
        elseif (Sensor.temperature >= (SETPOINT.setPoint + 0.2)) then -- turn off heat
            domoticz.devices(14).switchOff().checkFirst()
        else
            -- within hysteresis range
        end
    end
}
If I use domoticz/out I will get a text string, which I manipulate using the string object in Node Red.

I would like to read the information the same way from the Xiaomi device, but I'm not sure how to do this.

Can someone help me, please?

Best regards

Ulf
salvacalatayud
Posts: 112
Joined: Monday 26 June 2017 21:16
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Spain
Contact:

Re: Events from Xiaiomi devices

Post by salvacalatayud »

Hi,

I'm using node red to send temperature and setpoints to google home, maybe this can help you:

https://www.domoticz.com/forum/viewtopi ... 69&t=27588
ulfh2018
Posts: 65
Joined: Sunday 11 November 2018 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Oslo
Contact:

Re: Events from Xiaiomi devices

Post by ulfh2018 »

I have now found a solution - it was SO simple, when I finally did the right thing. I use the mqtt/in node connected to domoticz/in at Domoticz. Of course I first had to configure MQTT Remote on Domoticz. The result is formatted via the json parser, and the values picked out via a function. I am using mqtt on another Rpi, since I run into problems with instability when i tried mqtt on the same node where I was running Domoticz and Node-Red.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest