Publish MQTT Dzvents

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Publish MQTT Dzvents

Post by Cdzn »

Hi. I have this script

Code: Select all

return {
	on = {
	    devices = {
            'Переключатель котла'
    },
	   timer = 
		   {'every minute'}
        },
    
	logging = { level = domoticz.LOG_DEBUG },
	
	execute = function(dz,item,device)
	local function sendMQTT(message, topic)
            local MQTTTopic = topic or 'domoticz/out'
            osCommand ( 'mosquitto_pub  -u Cdzn -P Qq123e9 ' ..  ' -t '  .. MQTTTopic .. " -m '" .. message .. "'")
        end    
    if item.isTimer then 
    if (device.name == 'Переключатель котла' and device.active) then
        local myTopic = 'domoticz/out/' .. dz.devices('Переключатель котла').idx
            sendMQTT(myMessage, myTopic)
   
		end
  end
end
}
It should check if boiler switch is 'on' in domoticz and in espEasy is 'off' it should send 'On' command periodically. How to make it works? )
The reason is why i should do it, coz tonight boiler switch on and esp lost mqtt connection at the same time, so the command did not pass and i freeze(
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Publish MQTT Dzvents

Post by Cdzn »

Cdzn wrote: Tuesday 02 November 2021 8:07 Hi. I have this script

Code: Select all

return {
	on = {
	    devices = {
            'Переключатель котла'
    },
	   timer = 
		   {'every minute'}
        },
    
	logging = { level = domoticz.LOG_DEBUG },
	
	execute = function(dz,item,device)
	local function sendMQTT(message, topic)
            local MQTTTopic = topic or 'domoticz/out'
            osCommand ( 'mosquitto_pub  -u Cdzn -P Qq123e9 ' ..  ' -t '  .. MQTTTopic .. " -m '" .. message .. "'")
        end    
    if item.isTimer then 
    if (device.name == 'Переключатель котла' and device.active) then
        local myTopic = 'domoticz/out/' .. dz.devices('Переключатель котла').idx
            sendMQTT(myMessage, myTopic)
   
		end
  end
end
}
It should check if boiler switch is 'on' in domoticz and in espEasy is 'off' it should send 'On' command periodically. How to make it works? )
The reason is why i should do it, coz tonight boiler switch on and esp lost mqtt connection at the same time, so the command did not pass and i freeze(
I found a solution by repeating the switching command from Dzvents to espeasy. But if someone will help with mqtt publisher in dzvents i will appreciate it
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests