Is the character ( " ) or ( ’ ) missing in the script? I tried it now and it’s ok.
Linking .pioenvs/growatt-modbus/firmware.elf
RAM: [==== ] 42.9% (used 35168 bytes from 81920 bytes)
Flash: [===== ] 45.1% (used 470897 bytes from 1044464 bytes)
Building .pioenvs/growatt-modbus/firmware.bin
esp8266_copy_factory_bin([".pioenvs/growatt-modbus/firmware.bin"], [".pioenvs/growatt-modbus/firmware.elf"])
======================== [SUCCESS] Took 130.31 seconds ========================
INFO Successfully compiled program.
This is ok with me
esphome:
name: growatt-modbus
platform: ESP8266
board: d1_mini
substitutions:
esp_name: Growattmodbus
#Shift sunrise on minutes
shift_sunrise: '10'
wifi:
ssid: "SSID"
password: !secret wifi_key
use_address: 192.168.6.42
domain: !secret domain
ap:
ssid: "${esp_name} fb Hotspot"
password: !secret Fallback_Hotspot
captive_portal:
logger:
api:
ota:
time:
- platform: homeassistant
id: homeassistant_time
sun:
latitude: !secret latitude_data
longitude: !secret longitude_data
id: sun_sun
uart:
- id: uart1
baud_rate: 9600
tx_pin: D1
rx_pin: D2
modbus:
uart_id: uart1
web_server:
port: 80
sensor:
- platform: wifi_signal
name: "${esp_name} - ESP WiFi Signal"
update_interval: 60s
- platform: uptime
name: "${esp_name} - ESP Uptime"
icon: mdi:clock-outline
update_interval: 60s
- platform: growatt_solar
update_interval: 3s
protocol_version: RTU2
inverter_status:
name: "${esp_name} - Status Code"
id: inverter_status
phase_a:
voltage:
name: "${esp_name} - AC Voltage"
current:
name: "${esp_name} - AC Current"
active_power:
name: "${esp_name} - AC Power"
filters:
- filter_out: NaN
pv1:
voltage:
name: "${esp_name} - PV1 Voltage"
current:
name: "${esp_name} - PV1 Current"
active_power:
name: "${esp_name} - PV1 Power"
pv2:
voltage:
name: "${esp_name} - PV2 Voltage"
current:
name: "${esp_name} - PV2 Current"
active_power:
name: "${esp_name} - PV2 Power"
active_power:
state_class: "measurement"
name: "${esp_name} - Output Power"
filters:
- lambda: |-
if (x <= 5500 && x >= 0) return x;
else return 0;
pv_active_power:
name: "${esp_name} - Input Power"
frequency:
name: "${esp_name} - Grid Frequency"
energy_production_day:
name: "${esp_name} - Today Gen"
id: todaygen
filters:
lambda: |-
auto sunrise = id(sun_sun).sunrise(-0.833); //Get sunrise time
auto time = id(homeassistant_time).now(); //Get aktual time
if (!sunrise.has_value() and !time.is_valid()) //Validation sunrise and time data
return 0 ;
//1439 == 23:59 and 23:59 reset data to 0
if((sunrise.value().hour * 60 + sunrise.value().minute + ${shift_sunrise}) < (time.hour*60+time.minute) && (time.hour*60+time.minute) < 1439) {
return x;
}
else return 0;
total_energy_production:
name: "${esp_name} - Total Gen"
accuracy_decimals: 1
inverter_module_temp:
name: "${esp_name} - Temperature"
switch:
- platform: restart
name: "${esp_name} - ESP Restart"
text_sensor:
- platform: wifi_info
ip_address:
name: "${esp_name} IP Address"
ssid:
name: "${esp_name} Connected SSID"
bssid:
name: "${esp_name} Connected BSSID"
mac_address:
name: "${esp_name} Mac Wifi Address"
- platform: version
name: "${esp_name} - ESPHome Version"
sender
24
It compiles… now let’s see tomorrow morning
sender
25
I think today it worked. I keep watching it and report back.
Additionally I have 2 questions.
- Now when “the lambda” is in the is “no value”, can it send out 0 during tha time?
- during power loss/esp power down/esp unavailability the output in HA goes back to “no value” effective 0. How can I overcome that?
1 Like
1,
filters:
lambda: |-
auto sunrise = id(sun_sun).sunrise(-0.833);
auto time = id(homeassistant_time).now();
if(sunrise.has_value() && time.is_valid()){
if((sunrise.value().hour * 60 + sunrise.value().minute + ${shift_sunrise}) < (time.hour*60+time.minute) && (time.hour*60+time.minute) < 1439) {
if(String(id(todaygen).state) == "nan") return 0;
else return x;
}
else return 0;
}
else return 0;
2,
I´m not sure, but it will doesn´t work probably.
1 Like