Wallbox Energy Price Sensor should be a Number

We started the conversation in here: Wallbox Energy Price Sensor should be a Number · Issue #93614 · home-assistant/core · GitHub

Now, the wallbox upstream library accepts modification on the price, so it would be amazing being able to modify the price from HA :slight_smile:

The use case:

I would like to create an automation to dinamically set the charging price based on an input from another module (pvpc from spain).
The Voluntary Price for the Small Consumer tariff (the PVPC tariff) is the electricity rate you are on if you are in the regulated market and have a variable energy price: it changes every hour, 365 days a year. To be on the PVPC tariff you will be with one of the 5 benchmark energy companies (the traditional energy suppliers) in the regulated market.

WDYT?

Fully agreed on this one. I know @hesselonline has done work on the WallBox integration. Maybe he can tell how much work this would be.

I’d love to push my dynamic energy price to WallBox when it changes on the hour.

Edit: And I just read the GitHub issue progress. :slight_smile: It is a matter of finding someone to apply this update…

@hesselonline I think this is what I need to do. But I am unfamiliar with HASS development.

Can you provide guidance on how I can test this?

Found relevant resource. This’ll allow me to verify this before submitting a pull req. :sweat_smile:

I just took a few minutes to go over your code. In general, seems OK, don’t forget to change the wallbox package version in the manifest (one of the files in the component directory, and use hassfest (I think) to update the requirements file.

Also, give it a test-run, you should be able to run it locally and it should work. Finally, when tested and succesfull, home assistant requires automatic tests of your code, you should check with pytest whether test coverage is still OK after this code has been added. I might have some time this weekend to do a proper review and test it myself.

@hesselonline Tested it and it works.

I do get one unit test failure in an existing test I can’t fully comprehend yet.

If you could have a look, must be something simple. It is this one:

========================================================================== short test summary info ==========================================================================
FAILED tests/components/wallbox/test_number.py::test_wallbox_number_class_connection_error - Failed: DID NOT RAISE <class 'ConnectionError'>

Results (0.21s):
       2 passed
       1 failed
         - tests/components/wallbox/test_number.py:64 test_wallbox_number_class_connection_error

For manual testing, I ran HASS locally in dev container. Integrated with my wallbox account and used this manually triggered automation:

alias: New Automation
description: ""
trigger:
  - platform: event
    event_type: ""
condition: []
action:
  - device_id: [redacted]
    domain: number
    entity_id: [redacted]
    type: set_value
    value: 0.3
mode: single

The changed value (was 0.38) was visible in the testing HASS instance immediately. On my production it needed to timeout to the next sync. The logic to change this number triggers a refresh of the sensor value. So on the hass instance running this integration the update is near immediate.

1 Like