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

Energy usage over time #254

Closed
bigretromike opened this issue Dec 17, 2020 · 4 comments
Closed

Energy usage over time #254

bigretromike opened this issue Dec 17, 2020 · 4 comments
Labels
question Further information is requested

Comments

@bigretromike
Copy link

Hello,

Great work on project! Im unable to tazmotize most of the pluging thanks to tuya update, so I was hoping to make it run local.
I installed version 3.1 because master throw me errors (manual install).

I would like to add my power plug (16A) with power monitor to HA.

  - host: 192.168.0.41
    device_id: !secret dev
    local_key: !secret key
    friendly_name: power_plug_no4
    protocol_version: "3.3"
    entities:
      - platform: binary_sensor
        friendly_name: c594_status
        id: 1
        device_class: power
        state_on: "true" 
        state_off: "false"

      - platform: sensor
        friendly_name: c594_voltage
        id: 20
        scaling: 0.1
        device_class: voltage
        unit_of_measurement: "V"

      - platform: sensor
        friendly_name: c594_power
        id: 19
        scaling: 0.1
        device_class: energy
        unit_of_measurement: "W"

      - platform: sensor
        friendly_name: c594_current
        id: 18
        device_class: current
        unit_of_measurement: "mA"

      - platform: sensor
        friendly_name: c594_total
        id: 9
        device_class: power

      - platform: switch
        friendly_name: c594
        id: 1
        current: 18
        current_consumption: 19
        voltage: 20

I had hard time forcing proper entities name and end up with using friendly_name and then changing them to something better so Im getting proper name of entities now (also didnt know you have to remove device after modifying entities and names so the old one can be removed and new one will get create with new names - now they get assign to the old ones even when new friendly_name and 'name' and 'entities_namespece' does not work).

I was trying to add total_power_usage but id:9 probably is not that thing, tried with 25. and any other id.
(btw is there a quick way to list all available dp's without installing intergation via hasc (or how ever its called)?

I would like to have counter or some sort of way to count each month power usage for that plug - that was almost the main selling point for me because that the easiest way to monitor power usage without adding extra things to fuse box.

@postlund
Copy link
Collaborator

We only support friendly_name for simplicity, the entity id can be changed later as it becomes part of the entity register. Like you discovered. The integration will import from YAML every time you start Home Assistant and overwrite what was previously there. Removing the YAML config does not remove the config entry, so you need to remove YAML first, restart Home Assistant and then remove the device from Integrations to get rid of it.

The easiest way to figure out the datapoints it by adding the device via Configuration->Integrations as you will get lists presented with them there.

@postlund postlund added the question Further information is requested label Dec 17, 2020
@bigretromike
Copy link
Author

I'm new to HA world but I assume that if I define something in config I would like it to be repeatable on next machine using that config - i tried to do naming from inside yaml because it is my goal to test and tinker with it on test setup, and then move the yaml to proper installation thats why i was fighting with names.
And sadly no, its not the case you wrote.
I changed friendly_name to something different yet, the entities did not get overwriten, again even if I changed ID inside the entity the new entitie was made - I end up with 4 sensor.status_power when I was trying to figure out ID's. It looks like its a pair of type+id that were recognized or maybe that I was using friendly_name: Total power without guotes, not sure.

Im new to HA but each time I edit configuration.yaml i do restart ha with control panel - or do i need system reboot?

You are right, now I have localtuya in integration which is helpful, but Im still trying to add the most of my devices thru configuration.yaml so I can copy it over with fresh data and fresh system.

If I have you here, could you explain what is the point for:

        current: 18
        current_consumption: 19
        voltage: 20

when clearly those information are added to sensors with same id's? does it give extra information somewhere?

Going back to main issue,
How I can add sensor (or other type) to count the usage of given outlet using localtuya, this information is inside tuya app (smartlife) and it would be super important for me to have it inside HA without the 'cloud'

@ultratoto14
Copy link
Collaborator

ultratoto14 commented Dec 17, 2020

@bigretromike The aggregation is not accessible from the device itself, HA will get the power consumption and you should use other entities to aggregate.
Let say that your configuration creates a sensor representing the instant power consumption name sensor.c594_power
In your configuration add

sensor:

  - platform: integration
    source: sensor.c594_power
    name: c594_power_aggregation
    unit_time: h
    round: 1

utility_meter:

  c594_power_daily:
    source: sensor.c594_power_aggregation
    cycle: daily

This will introduce a new sensor named sensor.c594_power_aggregation that will convert your watts in wh and sum your total consumption since you created it. Then the utility_meter will create a sensor named sensor.c594_power_daily that will cycle every day and give you the daily consumption.

@bigretromike
Copy link
Author

@bigretromike The aggregation is not accessible from the device itself, HA will get the power consumption and you should use other entities to aggregate.
Let say that your configuration creates a sensor representing the instant power consumption name sensor.c594_power
In your configuration add

sensor:

  - platform: integration
    source: sensor.c594_power
    name: c594_power_aggregation
    unit_time: h
    round: 1

utility_meter:

  c594_power_daily:
    source: sensor.c594_power_aggregation
    cycle: daily

This will introduce a new sensor named sensor.c594_power_aggregation that will convert your watts in wh and sum your total consumption since you created it. Then the utility_meter will create a sensor named sensor.c594_power_daily that will cycle every day and give you the daily consumption.

Works flawless.

Thank you so much, I can now unplug my plugs from cloud :-) (if thats possible with localtuya), now I need to add reset of my plugs and other stuff. Lets the work begin :-) 👍

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

No branches or pull requests

3 participants