Hi,
I’m looking for a bit of help with uploading power, voltage, current, frequency, etc from a PZEM004 v3 to PVOutput dot org. The best reference I can find is a similar post on this forum but there’s assumed knowledge I don’t yet have:
I’ve spent a couple of days on trial and error and am not having any luck unfortunately. There appear to be bits of code that go into the automations.yaml, and other bits that go into configuration.yaml, then there’s somewhere else that the shell commands are supposed to go. I think I’d prefer that the everything stayed in my own yaml file if that is practical and/or possible.
shell_command, to be run every 5 minutes:
pvoutput_generation: 'curl -d "d={{now().strftime("%Y%m%d")}}" -d "t={{now().strftime("%H:%M")}}" -d "v2={{states.sensor.cs31011195_output_power.state|round(0)}}" -H "X-Pvoutput-Apikey: {{states.sensor.pvoutput_api_key.state}}" -H "X-Pvoutput-SystemId: {{states.sensor.pvoutput_system_id.state}}" https://pvoutput.org/service/r2/addstatus.jsp'
pvoutput_consumption: 'curl -d "d={{now().strftime("%Y%m%d")}}" -d "t={{now().strftime("%H:%M")}}" -d "c1=1" -d "v3={{(states.sensor.energy_consumption_tariff_1.state|int)+(states.sensor.energy_consumption_tariff_2.state|int)}}" -H "X-Pvoutput-Apikey: {{states.sensor.pvoutput_api_key.state}}" -H "X-Pvoutput-SystemId: {{states.sensor.pvoutput_system_id.state}}" https://pvoutput.org/service/r2/addstatus.jsp'
Also looked here but not sure how to use it
My hardware:
Current state is that my NodeMCU hardware connects with 2 x PZEM004 V3. I’ve installed HomeAssistant on a Win10 Virtual box host, made an initial config and can upload over the air no problem. I have a web server on the NodeMCU which is working, and all data from PZEM004 is available directly from the webserver, and in the HomeAssistant Overview tab, along with time.
Another option for the PVOutput upload command, run every 5 minutes like this (thanks IanJohnston dot com)
http.begin("http://pvoutput.org/service/r2/addstatus.jsp?d="+dateString+"&t="+timeString+"&v7="+String(DataImportPwrPV,1)+"&v8="+String(DataExportPwrPV,1)+"&v2="+String(DataGenPwrPV,1)+"&v10="+String(DataGenPwrPV,1)+"&v9="+String(DataActualConsumptionPwrPV,1)+"&v6="+String(DataVoltagePV,1)+"&v5="+String(DataTemperaturePV,1)+"&v4="+String(DataConsumptionPwrPV,1)+"&key="+sid +"&sid="+systemId);
My yaml config is currently thus, all working except for PVOutput upload. I might want to add another two PZEMs in future totaling 4 channels, and also create a Grafana dashboard:
esphome:
name: acpowermeter
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
web_server:
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Acpowermeter Fallback Hotspot"
password: "xxxxxxxxxxxxxxx"
captive_portal:
time:
- platform: sntp
id: sntp_time
modbus:
- id: mod1
uart_id: ua1
- id: mod2
uart_id: ua2
uart:
- id: ua1
rx_pin: D1
tx_pin: D2
baud_rate: 9600
#stop_bits: 1
- id: ua2
rx_pin: D3
tx_pin: D4
baud_rate: 9600
#stop_bits: 1
sensor:
- platform: pzemac
current:
name: "PZEM-004T V3 Current"
voltage:
name: "PZEM-004T V3 Voltage"
energy:
name: "PZEM-004T V3 Energy"
power:
name: "PZEM-004T V3 Power"
frequency:
name: "PZEM-004T V3 Frequency"
power_factor:
name: "PZEM-004T V3 Power Factor"
update_interval: 5s
modbus_id: mod1
- platform: pzemac
current:
name: "PZEM-004T_2 V3 Current"
voltage:
name: "PZEM-004T_2 V3 Voltage"
energy:
name: "PZEM-004T_2 V3 Energy"
power:
name: "PZEM-004T_2 V3 Power"
frequency:
name: "PZEM-004T_2 V3 Frequency"
power_factor:
name: "PZEM-004T_2 V3 Power Factor"
update_interval: 5s
modbus_id: mod2
text_sensor:
- platform: template
name: "Current time"
lambda: |-
char str[17];
time_t currTime = id(sntp_time).now().timestamp;
strftime(str, sizeof(str), "%Y-%m-%d %H:%M", localtime(&currTime));
return { str };
update_interval: 5s
Apologies for the long post, it would be great if some knowledgeable person could find a few moments to give some guidance,
Thanks