When 1 temp sensor is the same as 1 other turn something off

I have two temp sensors one Zigbee and one mqtt ,I want a routine to turn something off when the mqtt sensor is at the same temperature as the ZigBee one .

any help would be great .

thanks

martin

The following driver written by @Mariano_Colmenarejo does math. You need to use API Rules to put the data into the edge device it installs

thanks

martin

You can also try this example Rules API rule

The app Routines don’t have a condition to handle that. I can see why they might not want to support one.

You can do it easily enough using the Rules API with a Rule such as:

{
    "name": "Turn off a device if two temperature sensors have the same reading",
    "actions": [
        {
            "if": {
                "equals": {
                    "left": {
                        "device": {
                            "devices": [
                                "187814ee-eeed-4e9a-ae32-4c8e99e027d4"
                            ],
                            "component": "main",
                            "capability": "temperatureMeasurement",
                            "attribute": "temperature"
                        }
                    },
                    "right": {
                        "device": {
                            "devices": [
                                "625ab66e-b632-4c55-89dc-cd52993afa2c"
                            ],
                            "component": "main",
                            "capability": "temperatureMeasurement",
                            "attribute": "temperature"
                        }
                    }
                },
                "then": [
                    {
                        "command": {
                            "devices": [
                                "b7db0d43-dee3-4974-bd47-db34438aa814"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

Have you tested this rule?

Does the Rules API handle temperature values ​​with one decimal place?

(TIMMERFLOTTE 2)> emitting event: {"attribute_id":"temperature","capability_id":"temperatureMeasurement","component_id":"main","state":{"unit":"C","value":25.36}}

My Timmerflotte is emitting temperature values using two desimals.

Only with single decimal place temperature attributes this afternoon. With the typical home sensor only being accurate to 0.2 C, and the reporting sometimes defaulting to reporting 0.5 C changes, it isn’t something I’d do myself because a match might never happen.

Sounds a bit excessive to me.

I may have a play with virtual sensors after I’ve done the washing up.

Update: I forgot I had to get the washing in and change the bed clothes. However the Routine works fine with three decimal places.

hi i tried but am getting a request is malformed,

{
    "name": "Turn off a device if two temperature sensors have the same reading",
    "actions": [
        {
            "if": {
                "equals": {
                    "left": {
                        "device": {
                            "devices": [
                                "b99e319f-47ba-4758-84a8-68103b15e293"
                            ],
                            "component": "main",
                            "capability": "temperatureMeasurement",
                            "attribute": "temperature"
                        }
                    },
                    "right": {
                        "device": {
                            "devices": [
                                "bb46f49c-298d-40bd-bd17-9ac379ea1c6c"
                            ],
                            "component": "main",
                            "capability": "temperatureMeasurement",
                            "attribute": "temperature"
                        }
                    }
                },
                "then": [
                    {
                        "command": {
                            "devices": [
                                "0b14645b-e54d-4b41-b28b-ca83b244bcac"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}