Hi all,
I have domoticz running with quite a few sensor, switches and blockly sripts but am in need of some scripting blockly cannot di and I am not able to do lua or other programming sadly.
I would like to have a script that reads the P1 data and, with a PID controller, tries to keep the consumtion from the net at 0
so, setpoint for the PI controller is 0, process value is the net consumptrion and the output varies the PWM between 0 an 100%
this PWM needs to be send to an external esp8266 running espeasy or tasmota
i use this esp pwm output then to modulate a heater when there is enough solar power. Heater wil start using a wifi switch and once switched on can be controlled with the PWM signal that controls a kemo M240
would anyone be able to make such a script ?
Thanks !
Use P1 data to control to 0 consumption with PWM controller
Moderator: leecollings
-
- Posts: 30
- Joined: Thursday 01 September 2016 12:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Use P1 data to control to 0 consumption with PWM controller
-Domoticz-RFLink-PVoutput-Solarmeter-SBFSpot-ESPEasy-Volumio with spotify connect-
-
- Posts: 617
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: Use P1 data to control to 0 consumption with PWM controller
This one can get you started.
Code: Select all
-- Teruglevering
-- assumptions:
-- the setpoint is set by a dummy device (not a selector type)
-- http://192.168.2.110:8383/json.htm?type=devices&rid=15
local LED_gebruik = 'LED gebruik' -- switch device D7 GPIO 13
local LED_opbrengst = 'LED opbrengst' -- switch device D6 GPIO 12
local P1 = 'Power' -- P1 reading
--local LOGGING = true
return {
active = true,
on =
{
timer =
{
'every minute', -- between 20 minutes after sunrise and 20 minutes before sunset'
},
},
logging = {
--LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
level = domoticz.LOG_ERROR, -- domoticz.LOG_DEBUG for debug, to domoticz.LOG_ERROR when all OK
marker = "Teruglevering"
},
-- between 30 minutes after sunrise and 20 minutes before sunset'
--LOG level: This is the log level you want for this script. Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
--marker: A string that is prefixed before each log message. That way you can easily create a filter in the Domoticz log to see just these messages.
execute = function(dz)
-- domoticz.utils.dumpTable(item.json) -- dumpTable laat alle waarden zien, mooi voor debugging
-- collect all input data
local power_usage = dz.devices(P1).usage -- usage kan plus en min zijn
local power_delivery = dz.devices(P1).usageDelivered
-- info only on log level = LOG_DEBUG
dz.log('Gebruik : ' .. power_usage, dz.LOG_DEBUG)
dz.log('Teruglevering : ' .. power_delivery, dz.LOG_DEBUG)
if (power_delivery >= 2000) then
-- groene led aan
dz.devices(LED_opbrengst).switchOn()
dz.devices(LED_gebruik).switchOff()
elseif (power_delivery < 2000) and power_delivery > 10 then
-- groene led en rode led aan
dz.devices(LED_opbrengst).switchOn()
dz.devices(LED_gebruik).switchOn() --
elseif (power_delivery <= 10) then
-- rode led aan
dz.devices(LED_gebruik).switchOn() --
dz.devices(LED_opbrengst).switchOff()
end
end
}
-- einde Teruglevering
Bugs bug me.
Who is online
Users browsing this forum: No registered users and 1 guest