a529987659852 / openwbmqtt

Custom component for home assistant supporting openWB wallbox
35 stars 16 forks source link

Show and set "price based" charging max price #57

Open ubarni opened 10 months ago

ubarni commented 10 months ago

Hi,

it would be great to not only switch price based charging ON/OFF switch.openwb_cp1_preisbasiertes_laden_modus_sofortladen.

But also show and set the max price for charging: openWB/global/awattar/MaxPriceForCharging

Thanks... Barni

Bildschirmfoto 2023-10-14 um 09 54 19
ChristophCaina commented 10 months ago

I can give it a try to implement this, but I don't have a setup where I could test this. I think, the basic implementation should be similar to the settings for the current on different settings.

let me see, if I can implement this, but it will take some time.

ubarni commented 10 months ago

That would be great if you can implement this. I can test it and give you feedback. Thanks in advance...

ChristophCaina commented 10 months ago

OK, the most important question here is: Is there a SET Topic in MQTT that can be used to set the max_price

I could not find such topic 'adhoc'... so I need to do a bit more research. It would be great, if you could maybe also check if you can find something about this :)

ubarni commented 10 months ago

I found this and ran the Python code with my installation and it worked.

import paho.mqtt.publish as publish

def sendMqttEvent(hostname,topic,payload,qos=0):
    try:
        publish.single(topic, payload=payload, qos=qos, retain=False, hostname=hostname, port=1883, client_id="generic-client", keepalive=10, will=None, auth=None, tls=None, transport="tcp")
    except Exception as e:
        print("sendMqttEvent failed, because: %s"%e) 

sendMqttEvent('192.168.178.43','openWB/global/awattar/MaxPriceForCharging',51)
Bildschirmfoto 2023-11-10 um 09 59 52
ChristophCaina commented 9 months ago

Hey. Sorry - I hadn't the time to work on this... Unfortunately, this seems to be not as easy as I thought...

The topic that will be used is openWB/global/awattar/MaxPriceForCharging - but the current implementation of the Source Code is just using the following MQTT paths for the NUMBER entities:

    NUMBERS_GLOBAL_COPY = copy.deepcopy(NUMBERS_GLOBAL)
    for description in NUMBERS_GLOBAL_COPY:
        description.mqttTopicCommand = f"{mqttRoot}/config/set/{str(description.mqttTopicChargeMode)}/{description.mqttTopicCommand}"
        description.mqttTopicCurrentValue = f"{mqttRoot}/config/get/{str(description.mqttTopicChargeMode)}/{description.mqttTopicCurrentValue}"

Which means, I would need to modify the complete code for the Global Number entities. It would be easier, if the wallbox would also use one of the "config / get" and "config / set" paths for setting the maxprice... as this 'should' be the standard for changing settings on the Wallbox.

So basically: the awattar config does not really follow the defined standards or is not supposed to be changed from external.

ChristophCaina commented 9 months ago

https://github.com/snaptec/openWB/issues/2803