evcc-io / evcc

Sonne tanken ☀️🚘
https://evcc.io
MIT License
3.3k stars 602 forks source link

Give "tasmota-sml" template the option to set a custom jsonPrefix #14204

Closed osulivanDE closed 3 months ago

osulivanDE commented 3 months ago

Depending on which instructions users have followed to set up their Tasmota SML read head, it is possible that a wide variety of jsonPrefix variants have been set up there.

for example: +1,3,s,16,9600,MT681 Here is the documentation from Tasmota for this slug. Look for "jsonPrefix": https://tasmota.github.io/docs/Smart-Meter-Interface/#meter-definition

The EVCC template “tasmota-sml” requires the configuration as follows with a fixed "SML" as jsonPrefix +1,3,s,16,9600,SML

Docu here: https://docs.evcc.io/docs/devices/meters#tasmota-sml-ir-lesekopf-f%C3%BCr-smarte-stromz%C3%A4hler-bspw-hichi

The problem is that many other integrations are dependent on this jsonPrefix and it might not be easy to modify to the from EVCC required "SML"

Battery storage, HomeAssistant, solar integrations etc. might depend on this. It would therefore be nice if EVCC could adapt to a custom slug as it is possible with the custom template where you can set this jsonPrefix yourself with "jq":

  - name: Tasmota
    type: custom
    power:
        source: http
        uri: http://192.168.2.95...
        jq: .StatusSNS.MT681.Power_curr

This would also make it easier for people to switch from the custom template to the tasmota-sml template.

@andig maybe this makes it more easy to push users to the correct configuration as you mentioned here: https://github.com/evcc-io/evcc/pull/14146#issuecomment-2148995542

In my idea the configuration from tasmota-sml could look like this:

meters:
  - name: my_grid
    type: template
    template: tasmota-sml
    usage: grid
    host: 192.0.2.2 # IP-Adresse oder Hostname
    user: # Standard-User ist admin (optional)
    password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen) (optional) 
    jsonPrefix: #  JSON Payload Prefix. Standard ist: SML (optional)
premultiply commented 3 months ago

Ok, PR welcome!

andig commented 3 months ago

Just ignore any prefix?

osulivanDE commented 3 months ago

Even better since it makes it much more convenient for everyone.

premultiply commented 3 months ago

Just ignore any prefix?

Like this? select(.StatusSNS != null) | .. | .Power_curr? | select(type != "null")

premultiply commented 3 months ago

Sounds easy using jq but will need modification on how the JSON parsing inside Tasmota implementation is done.

/cc @thierolm

thierolm commented 3 months ago

I also thought about possible ways, to make the SML part of the Tasmota SML meter more flexible regarding the individual script flavours of the users, but it's not only the prefix which can be defined individually but also each reading parameter, e.g. Power_curr, which will be provided in the Tasmota response JSON. Trying to make the Tasmota SML template as flexible as possible, would lead to more configuration parameters. So why making evcc template more flexible and complex, by having the flexibility already on Tasmota script side?

thierolm commented 3 months ago

Idea: We are providing a tasmota-sml-http template, which configures a HTTP plugin config with many parameters to map the JSON tags and creates multiple HTTP requests to the SML device.

andig commented 3 months ago

Lets not do this ;) The request here was prefix. Is that still a relevant topic?

thierolm commented 3 months ago

Is that still a relevant topic?

Not for me.

osulivanDE commented 3 months ago

Lets not do this ;) The request here was prefix. Is that still a relevant topic?

For me yes. Being flexible in the jsonPrefix would be great.

@thierolm mentioned that the other parameters like Power_curr Power_p1, Total_in, ... might also be flexible since they are also variables on Tasmotas side. As far as i have seen diffreent setup guides for Tasmota-SML heads, those variables seem to be quite universal. Imho those do not have to be flexible.

thierolm commented 3 months ago

@osulivanDE Imho everything that's flexible on source side, has to be handeled on receiving side ... bec of the wide use of the tasmota SML devices and a lot of flavors of scripts, the next user is coming soon requesting flexibility on parameter name level ...

osulivanDE commented 3 months ago

Thanks to everyone. I totally understand your point @thierolm I for my side switched ESS, Solar and HA to the "SML" prefix and now use tasmota-sml