Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charging start/end time is not correct #6

Closed
SunnyCrockett opened this issue Feb 7, 2024 · 12 comments
Closed

Charging start/end time is not correct #6

SunnyCrockett opened this issue Feb 7, 2024 · 12 comments

Comments

@SunnyCrockett
Copy link
Contributor

The values I get for "Charging start time" and "Charging end time" are not correct:
image
image
I tried to get the correct values with modbus-cli and was successful with the following:
modbus dongle:502 -s 3 i@21319/I --byte-order=mixed
Parsed 0 registers definitions from 1 files
21319: 1707007290 0x65bedd3a
modbus dongle:502 -s 3 i@21317/I --byte-order=mixed
Parsed 0 registers definitions from 1 files
21317: 1706937153 0x65bdcb41

Those values are UNIX timestamps and could be converted to date/time. Unfortunately, I dont know how to configure the "--byte-order=mixed" option in HA yaml. Do you know how to do that?

Thanks & regards
Sunny

@Louisbertelsmann
Copy link
Owner

I‘ll figure something out. I did it some time ago, but a lot has changed. I also don‘t have that config anymore.

@Louisbertelsmann
Copy link
Owner

You might want to have a look at the swap option from homeassistant. There are a few options, but I don‘t know if the needed one is there.

@SunnyCrockett
Copy link
Contributor Author

Thanks for the hint with swap option, I have created a pull request with a fix that works for me:
image

Louisbertelsmann added a commit that referenced this issue Feb 8, 2024
@Louisbertelsmann
Copy link
Owner

Ok, thanks a lot. I will update the wiki and put it out of beta.

@btota
Copy link

btota commented Feb 10, 2024

update: perfect! Same for other uint32 values, update: we need to add swap:word to all uint32 registers!
grafik

pull request
- name: Maximum charging power
        unique_id: wb1_maximum_charging_power
        slave: !secret wallbox_modbus_slave
        address: 21272 # reg 21273
        input_type: input
        data_type: uint32
        swap: word
        precision: 1
        unit_of_measurement: W
        device_class: Power
        scale: 1
        scan_interval: 60

      - name: Total energy A
        unique_id: wb1_total_energy_a
        slave: !secret wallbox_modbus_slave
        address: 21299 # reg 21300
        input_type: input
        data_type: uint32
        swap: word
        precision: 1
        unit_of_measurement: Wh
        device_class: Energy
        scale: 1
        scan_interval: 600

@btota
Copy link

btota commented Feb 10, 2024

Working mode is input_type: holding
Mileage per kWh is input_type: holding

pull request
- name: Working mode
        unique_id: wb1_working_mode
        slave: !secret wallbox_modbus_slave
        address: 21262 # reg 21263
        input_type: holding #input
        data_type: uint16
        scan_interval: 600

- name: Mileage per kWh
        unique_id: wb1_mile_per_kwh
        slave: !secret wallbox_modbus_slave
        address: 21231 # reg 21232
        input_type: holding #input
        data_type: uint16
        scan_interval: 10

@SunnyCrockett
Copy link
Contributor Author

SunnyCrockett commented Feb 10, 2024

I have created a new pull request with some fixes and a new template.
Does anyone know, which registers are for fast charging, scheduled charging, surplus charging and so on like in the sungrow app?

@Louisbertelsmann
Copy link
Owner

It doesn't look like that exists, at least not in the official documentation.

@btota
Copy link

btota commented Feb 10, 2024

Not really - maybe an automation for each scenario is needed, can one also modbusscan with modbus-cli [0-248]?

@btota
Copy link

btota commented Feb 11, 2024

Wrong datetime (as_local):

pull request

template:
  - sensor:
      - name: Charging start time
        unique_id: wb1_charging_start_time
        state: >
          {{ as_local(as_datetime(states.sensor.charging_start_time_raw.state)).strftime("%d.%m.%Y %H:%M") }}

      - name: Charging end time
        unique_id: wb1_charging_end_time
        state: >
          {{ as_local(as_datetime(states.sensor.charging_end_time_raw.state)).strftime("%d.%m.%Y %H:%M") }}

needs to be changed to

template:
  - sensor:
      - name: Charging start time
        unique_id: wb1_charging_start_time
        state: >
          {{ (as_datetime(states.sensor.charging_start_time_raw.state)).strftime("%d.%m.%Y %H:%M") }}
      - name: Charging end time
        unique_id: wb1_charging_end_time
        state: >
          {{ (as_datetime(states.sensor.charging_end_time_raw.state)).strftime("%d.%m.%Y %H:%M") }}
    
      

@SunnyCrockett
Copy link
Contributor Author

Without the as_local, it is in utc0. I am in utc+1 and wanted it shown like in the iCloudSolar app. Whats your timezone in HA?

@btota
Copy link

btota commented Feb 11, 2024

Weird. Timezone on HA is gmt+01:00 Berlin. Using as_local caused right timestamp +1 hour :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants