reserve85 / HoymilesZeroExport

Zero Export Script for Hoymiles Inverters using AhoyDTU / OpenDTU and Tasmota Smart Meter inferface / Shelly 3EM / SHRDZM / Emlog / ioBroker
GNU General Public License v3.0
135 stars 31 forks source link

Shelly 3 EM mit Passwortabfrage in der Config #61

Closed XpertXXL closed 1 year ago

XpertXXL commented 1 year ago

könnte man beim Shelly EM 3 auch noch die Option des Passwort Schutzes umsetzen. (Abfrage in der HoymilesZeroExport_Config.ini) Ich habe alle meine Shelly's normalerweise Passwort geschützt. Danke auch für das tolle Script!

XpertXXL

reserve85 commented 1 year ago

Hi,

gute Idee. Habe es mal in der DEV implementiert: https://github.com/reserve85/HoymilesZeroExport/tree/dev

Ich konnte es mit einem Shelly 1PM testen, sollte also auch mit dem 3EM klappen. Leider habe ich keinen Shelly der 2. Generation greifbar, (PLUS_1PM, 3EM_PRO) kann das ggf. jemand testen? Habe es zwar wie in der API beschrieben umgesetzt aber man weiß ja nie...

XpertXXL commented 1 year ago

mit EM 3 getestet, klappt :-) vielen Dank

reserve85 commented 1 year ago

top, @onceuponatime78 kannst du das ggf. auch mit deinem Shelly Pro 3EM testen (falls du das Script noch laufen hast...)

onceuponatime78 commented 1 year ago

hab es kurz ausprobiert und es funktioniert auf Anhieb nicht - der Unterschied den ich auf die schnelle zwischen den shelly generationen erkennen konnte ist, dass bei den Pro Geräten nur ein Passwort gesetzt wird, bei den älteren user+passwort

reserve85 commented 1 year ago

ja hab grad geschaut, der User ist immer "admin" bei den GEN2 Produkten. Kannst du das dann mal im Browser probieren: http://admin:PASS@xxx.xxx.xxx.xxx/rpc/EM.GetStatus?id=0

Gruß Tobi

onceuponatime78 commented 1 year ago

mit aktivierter passwortauthentifizierung: {"code":404,"message":"No handler for EM.GetStatus/"}

reserve85 commented 1 year ago

Mist. Mit welchem Shelly hast du das getestet? Pro 3EM oder 1PM Plus?

onceuponatime78 commented 1 year ago

mit dem pro 3EM - mit deaktiviertem PW wird der Status zurückgeliefert

reserve85 commented 1 year ago

Ein Versuch hätte ich noch, falls du nochmal dazu kommst -> https://github.com/reserve85/HoymilesZeroExport/tree/dev Wäre echt top. in der config dann "admin" und dein Passwort.

delacor commented 1 year ago

Ich kriegs nicht ganz zum laufen, vermute aber der Fehler liegt bei mir. habe auch den shelly 3EM Pro

INFO     OpenDTU: Inverter "HM-1500" reachable: True
INFO     OpenDTU: Inverter "HM-1500" temperature: 33.1 degC
ERROR    Exception at GetPowermeterWatts
ERROR    Expecting value: line 1 column 1 (char 0)
ERROR    Expecting value: line 1 column 1 (char 0)


[VERSION]                                                                                                                                                                                                                                                                                                                                                    
VERSION = 1.33                                                                                                                                                                                                                                                                                                                                               

[SELECT_DTU]                                                                                                                                                                                                                                                                                                                                                 
# --- define your DTU (only one) ---                                                                                                                                                                                                                                                                                                                         
USE_AHOY = false                                                                                                                                                                                                                                                                                                                                             
USE_OPENDTU = true                                                                                                                                                                                                                                                                                                                                           

[SELECT_POWERMETER]                                                                                                                                                                                                                                                                                                                                          
# --- define your Powermeter (only one) ---                                                                                                                                                                                                                                                                                                                  
USE_TASMOTA = false                                                                                                                                                                                                                                                                                                                                          
USE_SHELLY_3EM = false                                                                                                                                                                                                                                                                                                                                       
USE_SHELLY_3EM_PRO = true                                                                                                                                                                                                                                                                                                                                    
USE_SHRDZM = false                                                                                                                                                                                                                                                                                                                                           
USE_EMLOG = false                                                                                                                                                                                                                                                                                                                                            
USE_IOBROKER = false                                                                                                                                                                                                                                                                                                                                         
USE_HOMEASSISTANT = true                                                                                                                                                                                                                                                                                                                                     

[AHOY_DTU]                                                                                                                                                                                                                                                                                                                                                   
# --- defines for AHOY-DTU ---                                                                                                                                                                                                                                                                                                                               
# in settings/inverter set interval to 6 seconds!                                                                                                                                                                                                                                                                                                            
AHOY_IP = 192.168.10.57                                                                                                                                                                                                                                                                                                                                      

[OPEN_DTU]                                                                                                                                                                                                                                                                                                                                                   
# --- defines for OPEN-DTU ---                                                                                                                                                                                                                                                                                                                               
OPENDTU_IP = 10.4.20.187                                                                                                                                                                                                                                                                                                                                     
OPENDTU_USER = admin                                                                                                                                                                                                                                                                                                                                         
OPENDTU_PASS = 8chars1number                                                                                                                                                                                                                                                                                                                                   

[TASMOTA]                                                                                                                                                                                                                                                                                                                                                    
# --- defines for Tasmota Smartmeter Modul---                                                                                                                                                                                                                                                                                                                
TASMOTA_IP = 192.168.10.90                                                                                                                                                                                                                                                                                                                                   
# the following three constants describes how to navigate through the Tasmota-JSON.                                                                                                                                                                                                                                                                          
# if you do not know the format of your Tasmota reader, open a browser and put in the following string replacing xxx with the IP address of your Tasmota device: http://xxx.xxx.xxx.xxx/cm?cmnd=status%2010                                                                                                                                                  
# e.g. JSON_Result = {"StatusSNS":{"Time":"2023-02-28T12:49:49","SML":{"total_kwh":15011.575,"curr_w":-71}}}                                                                                                                                                                                                                                                 
TASMOTA_JSON_STATUS = StatusSNS                                                                                                                                                                                                                                                                                                                              
# Prefix for Web UI and MQTT JSON payload                                                                                                                                                                                                                                                                                                                    
TASMOTA_JSON_PAYLOAD_MQTT_PREFIX = SML                                                                                                                                                                                                                                                                                                                       
# Power-MQTT label (the current power in Watt, positive (import more energy than export) or negative (export more energy than import)).                                                                                                                                                                                                                      
TASMOTA_JSON_POWER_MQTT_LABEL = curr_w                                                                                                                                                                                                                                                                                                                       
# if your powermeter does NOT output the current power: you need to calculate it -> Power(W) = OBIS(1.7.0) - OBIS(2.7.0)                                                                                                                                                                                                                                     
TASMOTA_JSON_POWER_CALCULATE = FALSE                                                                                                                                                                                                                                                                                                                         
# Power-MQTT Input label (positive active instantaneous power, e.g. OBIS Code 1.7.0)                                                                                                                                                                                                                                                                         
TASMOTA_JSON_POWER_INPUT_MQTT_LABEL =                                                                                                                                                                                                                                                                                                                        
# Power-MQTT output label (negative active instantaneous power, e.g. OBIS Code 2.7.0)                                                                                                                                                                                                                                                                        
TASMOTA_JSON_POWER_OUTPUT_MQTT_LABEL =                                                                                                                                                                                                                                                                                                                       

[SHELLY_3EM]                                                                                                                                                                                                                                                                                                                                                 
# --- defines for Shelly ---                                                                                                                                                                                                                                                                                                                                 
SHELLY_IP = 10.4.20.9                                                                                                                                                                                                                                                                                                                                        
SHELLY_USER = admin                                                                                                                                                                                                                                                                                                                                          
SHELLY_PASS = 8chars1number                                                                                                                                                                                                                                                                                                                                  
[SHRDZM]                                                                                                                                                                                                                                                                                                                                                     
# --- defines for SHRDZM Smartmeter Modul ---                                                                                                                                                                                                                                                                                                                
SHRDZM_IP = xxx.xxx.xxx.xxx                                                                                                                                                                                                                                                                                                                                  
SHRDZM_USER =                                                                                                                                                                                                                                                                                                                                                
SHRDZM_PASS =                                                                                                                                                                                                                                                                                                                                                

[EMLOG]                                                                                                                                                                                                                                                                                                                                                      
# --- defines for EMLOG (electronic meter log) System ---                                                                                                                                                                                                                                                                                                    
EMLOG_IP = xxx.xxx.xxx.xxx                                                                                                                                                                                                                                                                                                                                   
EMLOG_METERINDEX =                                                                                                                                                                                                                                                                                                                                           

[IOBROKER]                                                                                                                                                                                                                                                                                                                                                   
# --- defines for IOBROKER (make sure you installed https://github.com/ioBroker/ioBroker.simple-api) ---                                                                                                                                                                                                                                                     
IOBROKER_IP = xxx.xxx.xxx.xxx                                                                                                                                                                                                                                                                                                                                
IOBROKER_PORT = 8087                                                                                                                                                                                                                                                                                                                                         
IOBROKER_CURRENT_POWER_ALIAS = alias.0.Zaehler.Zaehler_CurrentWatt                                                                                                                                                                                                                                                                                           
# if your powermeter does NOT output the current power: you need to calculate it -> Power(W) = OBIS(1.7.0) - OBIS(2.7.0)                                                                                                                                                                                                                                     
IOBROKER_POWER_CALCULATE = FALSE                                                                                                                                                                                                                                                                                                                             
# Power-MQTT Input label (positive active instantaneous power, e.g. OBIS Code 1.7.0)                                                                                                                                                                                                                                                                         
IOBROKER_POWER_INPUT_ALIAS = alias.0.Zaehler.Zaehler_CurrentInputWatt                                                                                                                                                                                                                                                                                        
# Power-MQTT output label (negative active instantaneous power, e.g. OBIS Code 2.7.0)                                                                                                                                                                                                                                                                        
IOBROKER_POWER_OUTPUT_ALIAS = alias.0.Zaehler.Zaehler_CurrentOutputWatt                                                                                                                                                                                                                                                                                      

[HOMEASSISTANT]                                                                                                                                                                                                                                                                                                                                              
# --- defines for HOME ASSISTANT ---                                                                                                                                                                                                                                                                                                                         
HA_IP = 10.4.20.140                                                                                                                                                                                                                                                                                                                                          
HA_PORT = 8123                                                                                                                                                                                                                                                                                                                                               
# you need to create a Long-Lived Access Token in your Home Assistant: click on your profile, then scroll down to the bottom                                                                                                                                                                                                                                 
HA_ACCESSTOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVh-SCNZbSSzHNcAJzcr7xhwTzYI                                                                                                                                                     
HA_CURRENT_POWER_ENTITY = sensor.power_ges                                                                                                                                                                                                                                                                                                                   
# if your powermeter does NOT output the current power: you need to calculate it -> Power(W) = OBIS(1.7.0) - OBIS(2.7.0)                                                                                                                                                                                                                                     
HA_POWER_CALCULATE = FALSE                                                                                                                                                                                                                                                                                                                                   
# Power-MQTT Input label (positive active instantaneous power, e.g. OBIS Code 1.7.0)                                                                                                                                                                                                                                                                         
HA_POWER_INPUT_ALIAS = sensor.power_ges                                                                                                                                                                                                                                                                                                                      
# Power-MQTT output label (negative active instantaneous power, e.g. OBIS Code 2.7.0)                                                                                                                                                                                                                                                                        
HA_POWER_OUTPUT_ALIAS = sensor.power_ges                                                                                                                                                                                                                                                                                                                     

[SELECT_INTERMEDIATE_METER]                                                                                                                                                                                                                                                                                                                                  
# if you have an intermediate meter ("Zwischenzähler") to measure the outputpower of your inverter you can set it here. It is faster than the DTU current_power value                                                                                                                                                                                        
# --- define your intermediate meter - if you don´t have one set the following defines to false to use the value from your DTU---                                                                                                                                                                                                                            
USE_TASMOTA_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                             
USE_SHELLY_3EM_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                          
USE_SHELLY_3EM_PRO_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                      
USE_SHELLY_1PM_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                          
USE_SHELLY_PLUS_1PM_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                     
USE_SHRDZM_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                              
USE_EMLOG_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                               
USE_IOBROKER_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                            
USE_HOMEASSISTANT_INTERMEDIATE = false                                                                                                                                                                                                                                                                                                                       

[INTERMEDIATE_TASMOTA]                                                                                                                                                                                                                                                                                                                                       
# --- defines for Tasmota Smartmeter Modul---                                                                                                                                                                                                                                                                                                                
TASMOTA_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                     
# the following three constants describes how to navigate through the Tasmota-JSON                                                                                                                                                                                                                                                                           
# e.g. JSON_Result = {"StatusSNS":{"Time":"2023-02-28T12:49:49","SML":{"curr_w":500}}}                                                                                        
TASMOTA_JSON_STATUS_INTERMEDIATE = StatusSNS                                                                                                                                  
# Prefix for Web UI and MQTT JSON payload                                                                                                                                     
TASMOTA_JSON_PAYLOAD_MQTT_PREFIX_INTERMEDIATE = SML                                                                                                                           
# Power-MQTT label (the current solar-power in Watt).                                                                                                                         
TASMOTA_JSON_POWER_MQTT_LABEL_INTERMEDIATE = curr_w                                                                                                                           

[INTERMEDIATE_SHELLY]                                                                                                                                                         
# --- defines for Shelly ---                                                                                                                                                  
SHELLY_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                      
# if you restricted the web login enter your username and password, for Shelly "Generation 2" devices the username is always "admin" (e.g. Shelly pro 3EM)                                                                                                                                                                                                   
SHELLY_USER_INTERMEDIATE =                                                                                                                                                    
SHELLY_PASS_INTERMEDIATE =                                                                                                                                                    
[INTERMEDIATE_SHRDZM]                                                                                                                                                         
# --- defines for SHRDZM Smartmeter Modul ---                                                                                                                                 
SHRDZM_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                      
SHRDZM_USER_INTERMEDIATE =                                                                                                                                                    
SHRDZM_PASS_INTERMEDIATE =                                                                                                                                                    

[INTERMEDIATE_EMLOG]                                                                                                                                                          
# --- defines for EMLOG (electronic meter log) System ---                                                                                                                     
EMLOG_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                       
EMLOG_METERINDEX_INTERMEDIATE =                                                                                                                                               

[INTERMEDIATE_IOBROKER]                                                                                                                                                       
# --- defines for IOBROKER (needs installed https://github.com/ioBroker/ioBroker.simple-api) ---                                                                                                                                                                                                                                                             
IOBROKER_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                    
IOBROKER_PORT_INTERMEDIATE = 8087                                                                                                                                             
IOBROKER_CURRENT_POWER_ALIAS_INTERMEDIATE = alias.0.Zaehler.Zaehler_SolarCurrentWatt                                                                                          

[INTERMEDIATE_HOMEASSISTANT]                                                                                                                                                  
# --- defines for HOME ASSISTANT (you need to create a Long-Lived Access Token in your profile) ---                                                                                                                                                                                                                                                          
HA_IP_INTERMEDIATE = xxx.xxx.xxx.xxx                                                                                                                                          
HA_PORT_INTERMEDIATE = 8123                                                                                                                                                   
HA_ACCESSTOKEN_INTERMEDIATE = xxx                                                                                                                                             
HA_CURRENT_POWER_ENTITY_INTERMEDIATE = sensor.dtz541_sml_curr_w                                                                                                               

[COMMON]                                                                                                                                                                      
# Number of Inverters                                                                                                                                                         
INVERTER_COUNT = 1                                                                                                                                                            
# max difference in percent between SetpointLimit change to approximate the power to new setpoint                                                                                                                                                                                                                                                            
SLOW_APPROX_LIMIT_IN_PERCENT = 20                                                                                                                                             
# if slow approximation: additional limit based on the limit-difference to "smoot the curve": newLimitSetpoint = newLimitSetpoint + (LimitDifference * SLOW_APPROX_FACTOR_IN_PERCENT / 100)                                                                                                                                                                  
SLOW_APPROX_FACTOR_IN_PERCENT = 20                                                                                                                                            
# interval time for setting limit to Hoymiles                                                                                                                                 
LOOP_INTERVAL_IN_SECONDS = 7                                                                                                                                                  
# delay time after sending limit to Hoymiles Inverter                                                                                                                         
SET_LIMIT_DELAY_IN_SECONDS = 3                                                                                                                                                
# delay time after sending limit to Hoymiles Inverter when using more than one Inverter                                                                                       
SET_LIMIT_DELAY_IN_SECONDS_MULTIPLE_INVERTER = 2                                                                                                                              
# polling interval for powermeter (must be < LOOP_INTERVAL_IN_SECONDS)                                                                                                        
POLL_INTERVAL_IN_SECONDS = 2                                                                                                                                                  
# when powermeter > 0: (True): always jump to maxLimit of inverter; (False): increase limit based on previous limit                                                                                                                                                                                                                                          
JUMP_TO_MAX_LIMIT_ON_GRID_USAGE = false                                                                                                                                       
# max difference between Limit and real output power in % of HOY_MAX_WATT (100 = disabled)                                                                                    
MAX_DIFFERENCE_BETWEEN_LIMIT_AND_OUTPUTPOWER = 10                                                                                                                             
# enable logging to file                                                                                                                                                      
ENABLE_LOG_TO_FILE = false                                                                                                                                                    
# how many logfiles you wish to keep                                                                                                                                          
LOG_BACKUP_COUNT = 30                                                                                                                                                         
# defines how often a identical limit will be set, set it to "-1" for disabled (infinite repeat)                                                                                                                                                                                                                                                             
SET_LIMIT_RETRY = 10                                                                                                                                                          
# log the inverter temperature                                                                                                                                                
LOG_TEMPERATURE = true                                                                                                                                                        
# delay time after turning the inverter off or on                                                                                                                             
SET_POWER_STATUS_DELAY_IN_SECONDS = 10                                                                                                                                        

[CONTROL]                                                                                                                                                                     
# --- global defines for control behaviour ---                                                                                                                                
# this is the target power for powermeter in watts                                                                                                                            
POWERMETER_TARGET_POINT = -10                                                                                                                                                 
# this is the tolerance (pos and neg) around the target point. in this range no adjustment will be set                                                                                                                                                                                                                                                       
POWERMETER_TOLERANCE = 20                                                                                                                                                     
# this is the max power to regulate the limit. if your powermeter is above this point, the limit jumps to 100% (when JUMP_TO_MAX_LIMIT_ON_GRID_USAGE is set to TRUE). Must be higher than POWERMETER_TARGET_POINT + POWERMETER_TOLERANCE                                                                                                                     
POWERMETER_MAX_POINT = 0                                                                                                                                                      

# List of INVERTERS, based on COMMON/COUNT                                                                                                                                    
[INVERTER_1]                                                                                                                                                                  
# power rating of your inverter                                                                                                                                               
HOY_MAX_WATT = 1300                                                                                                                                                           
# minimum limit in percent, e.g. 5%                                                                                                                                           
HOY_MIN_WATT_IN_PERCENT = 5                                                                                                                                                   
# factor to multiply before set Limit. Some Inverters have some offsets, with that factor you can compensate it. Default = 1                                                                                                                                                                                                                                 
HOY_COMPENSATE_WATT_FACTOR = 1                                                                                                                                                
# battery powered?                                                                                                                                                            
HOY_BATTERY_MODE = false                                                                                                                                                      
# voltage to turn off the inverter                                                                                                                                            
HOY_BATTERY_THRESHOLD_OFF_LIMIT_IN_V = 47                                                                                                                                     
# voltage to limit the inverter to a maximum of HOY_BATTERY_REDUCE_WATT                                                                                                       
HOY_BATTERY_THRESHOLD_REDUCE_LIMIT_IN_V = 48                                                                                                                                  
# voltage to limit the inverter to a maximum of HOY_BATTERY_NORMAL_WATT                                                                                                       
HOY_BATTERY_THRESHOLD_NORMAL_LIMIT_IN_V = 48.5                                                                                                                                
# maximum limit in watts when battery is high (above HOY_BATTERY_THRESHOLD_NORMAL_LIMIT_IN_V)                                                                                                                                                                                                                                                                
HOY_BATTERY_NORMAL_WATT = 1500                                                                                                                                                
# maximum limit in watts when battery is low (below HOY_BATTERY_THRESHOLD_REDUCE_LIMIT_IN_V)                                                                                                                                                                                                                                                                 
HOY_BATTERY_REDUCE_WATT = 300                                                                                                                                                 
# reenable inverter at this voltage                                                                                                                                           
HOY_BATTERY_THRESHOLD_ON_LIMIT_IN_V = 51                                                                                                                                      
reserve85 commented 1 year ago

Hey, Hast du ein Passwort eingestellt bei dem Shelly 3EM Pro? Es kann sein dass das nämlich noch nicht funktioniert, da ich keinen habe konnte es nicht testen. -> Abhilfe: entferne das Passwort bei dem 3EM pro (und setze den Username / Passwort auf leer in der Ini), dann sollte es klappen. Die MAIN Version sollte ebenfalls funktionieren.

delacor commented 1 year ago

Achso ja alles gut, mir ging es eher darum dir dabei zu helfen, leider ist das logfile nicht sehr aussagekräftig. Ich Versuche nachher genauer herauszufinden, wo es hakt.

reserve85 commented 1 year ago

Ahso ok - danke schonmal! scheint also nicht zu klappen? ich kapiere es nicht so richtig, ohne codebeispiel in Python bekomme ich es irgendwie nicht hin. Siehe https://shelly-api-docs.shelly.cloud/gen2/0.14/General/Authentication#authentication

delacor commented 1 year ago

Jau, das ist etwas komplizierter, da die das ganzen hashen wollen. Ich habe hier was gefunden, ist auch für Gen2, könnte man so kopieren.

reserve85 commented 1 year ago

Jop das hab ich auch vorhin gesehen. Halte das aber etwas oversized, dann verzichte ich lieber auf die authentication.

delacor commented 1 year ago

Got it.

import requests
>>> from requests.auth import HTTPDigestAuth
>>> url = 'http://10.4.20.9/rpc/EM.GetStatus?id=0'
>>> requests.get(url, auth=HTTPDigestAuth('admin', '8chars1number'))
<Response [200]>
reserve85 commented 1 year ago

Leck am arsch, bin heute unterwegs ich implementiere es heute Abend! 1000 Dank.

delacor commented 1 year ago

hab dir https://github.com/reserve85/HoymilesZeroExport/pull/64 schon reingedrückt :-)

reserve85 commented 1 year ago

ist in der MAIN, vielen Dank!