gtdiehl / iotawatt_ha

IoTaWatt for Home Assistant
Apache License 2.0
16 stars 16 forks source link

All outputs are missing in 0.1.1 #29

Open darek-margas opened 3 years ago

darek-margas commented 3 years ago

After upgrading to 0.1.1 new sensors were created. As per warning notice iotawatt_something prefix was removed. However, only input sensors are present. I wonder how it is expected to work if I name output sensor the same as input? Regardless, it is simply broken. I tried this 2021.9 embedded one with exactly the same result.

gtdiehl commented 3 years ago

Is your Input and Output named the same in the IoTaWatt web interface?

The Input and Output should be created in HA just that the Output will have appended _2 to the name so it does not conflict with the Input.

If there is still an issue can you look in the logs, are there any errors from IoTaWatt?

gtdiehl commented 3 years ago

Also how are you looking for the sensors? Through the Entities page? Developer Tools? Or from the drop down selection list in the Energy Dashboard configuration?

jyavenard commented 3 years ago

After upgrading to 0.1.1 new sensors were created. As per warning notice iotawatt_something prefix was removed. However, only input sensors are present. I wonder how it is expected to work if I name output sensor the same as input? Regardless, it is simply broken. I tried this 2021.9 embedded one with exactly the same result.

The output sensors are not showing in the iotawatt integration; instead they are showing up as a plain sensor.

It's how the HA iotawatt integration, and it's plain silly. I opened a bug there: https://github.com/home-assistant/core/issues/55489 but it was closed.

bmorgan99 commented 3 years ago

Logger: homeassistant.helpers.event Source: components/integration/sensor.py:163 First occurred: 10:00:40 AM (3 occurrences)

Last logged: 10:00:40 AM

Error while processing state change for sensor.mainsconsumption
Error while processing state change for sensor.mainsexport
Error while processing state change for sensor.notmonitored
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 272, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/integration/sensor.py", line 163, in calc_integration
    or new_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE)
AttributeError: 'NoneType' object has no attribute 'state'

I'm not seeing the input data in energy-devices-graph either. It was there yesterday after the update.

gtdiehl commented 3 years ago

@bmorgan99 What version of HA are you running?

bmorgan99 commented 3 years ago

2021.9.0

gtdiehl commented 3 years ago

@bmorgan99 The custom_component of the IoTaWatt only supports up to HA 2021.8.x

For 2021.9.0 you would have to use the official integration bundled with HA 2021.9.0. After uninstalling the custom component, restarting HA, and adding the official integration you will need to create a sensor for each input and output that is from the IoTaWatt that has a unit type of Watts. The template format is documented here IoTaWatt

bmorgan99 commented 3 years ago

Yes, I uninstalled the HACS version, created the 2 integration sensors per the doc, upgraded to 9.0 and installed the core integration. I didn't see anything about creating each input, but they now look like this:

sensor.iotawatt_input_oven_wh

type: Input
channel: 3
unit_of_measurement: Wh
friendly_name: Oven (E)
device_class: energy

sensor.iotawatt_input_oven

state_class: measurement
type: Input
channel: 3
unit_of_measurement: W
friendly_name: Oven (W)
device_class: power

so create this in sensor.yaml?

- platform: integration
  source: sensor.iotawatt_input_oven
  name: Oven (k)
  unit_prefix: k
jyavenard commented 3 years ago

See https://github.com/home-assistant/core/issues/55554

this is due to an unfortunate last minute change in the HA integration.

Note that if you use the version propose here https://github.com/gtdiehl/iotawatt_ha/pull/30

not only the sensor will work with the energy graph, but you’ll get much better accuracy than the integration in HA offers

platform: integration source: sensor.iotawatt_input_oven name: Oven (k) unit_prefix: k

your source is incorrect, the sensors have been renamed. The prefix iotawatt_input is gone

darek-margas commented 3 years ago

Is your Input and Output named the same in the IoTaWatt web interface?

The Input and Output should be created in HA just that the Output will have appended _2 to the name so it does not conflict with the Input.

If there is still an issue can you look in the logs, are there any errors from IoTaWatt?

Initially I installed your integration early 2021.8. I ran REST too as there was an issue with non-volt/watt values. It was fine on 0.0.8. I updated HA to 2021.9 and it was still fine. Then I saw your recent update. I deconfigured integration, removed it from hacs install and reconfigured using embedded integration. It created 19 sensors for all input channels and that's it. Alright, I reverted snap I took before changes. Got back on previous version working as before. I ran update via hacs instead and... same result. 19 new sensors and my previous 37 still there marked missing now. Created new output for test - has not been discovered. Reverted snap again and left it as it was. No errors in log.

jyavenard commented 3 years ago

I ran REST too as there was an issue with non-volt/watt values. It was fine on 0.0.8.

I've noticed the same ; the sensor are there ; but they are disabled by default ; another last minute change that broke a lot of things :(

gtdiehl commented 3 years ago

Is your Input and Output named the same in the IoTaWatt web interface?

The Input and Output should be created in HA just that the Output will have appended _2 to the name so it does not conflict with the Input.

If there is still an issue can you look in the logs, are there any errors from IoTaWatt?

Initially I installed your integration early 2021.8. I ran REST too as there was an issue with non-volt/watt values.

It was fine on 0.0.8.

I updated HA to 2021.9 and it was still fine.

Then I saw your recent update. I deconfigured integration, removed it from hacs install and reconfigured using embedded integration. It created 19 sensors for all input channels and that's it. Alright, I reverted snap I took before changes. Got back on previous version working as before. I ran update via hacs instead and... same result. 19 new sensors and my previous 37 still there marked missing now. Created new output for test - has not been discovered.

Reverted snap again and left it as it was.

No errors in log.

@darek-margas Where are you looking for the test output sensor that was created? Entities page? Developer Tools? Or another area?

darek-margas commented 3 years ago

@darek-margas Where are you looking for the test output sensor that was created? Entities page? Developer Tools? Or another area?

I looked in entities filtered by integration. I see from the above they might appear as unrelated thus out of filter scope.

gtdiehl commented 3 years ago

@darek-margas If you clear the filter you should see your Output sensors on the Entities page. The Outputs will have an Integration of Sensor. Did you find them?

darek-margas commented 3 years ago

@darek-margas If you clear the filter you should see your Output sensors on the Entities page. The Outputs will have an Integration of Sensor. Did you find them?

As I mentioned earlier I reverted this change to continue with my monitoring and automation. Now it is as if I never updated it. I'll wait for a few tags on 2021.9 (already has 1) and re-attempt one day. Knowing sensors will appear as unrelated I may have better chance (and still lots of work to rename my 37 sensors back as they are referred in so many places...

gtdiehl commented 3 years ago

Can I close this issue then?

darek-margas commented 3 years ago

I think it would be better to actually change it and make all sensor related to integration.

jyavenard commented 3 years ago

Please comment in https://github.com/home-assistant/core/issues/55489 and open a new bug referring to that issue. Hopefully if enough people mention it they will revisit this very unfortunate choice.

darek-margas commented 3 years ago

Can I close this issue then?

Alright, I attempted to do it again. it turned badly anyway. I found all these missing sensors. I was able to rename these not missing back to what they were. Then, I found these "missing" ones lost their unique ID and as such they can't be modified in UI. Previous integration gave unique IDs to all. I like idea of this integration but if someone believes removing IDs was good idea, then I will be better of running REST instead. At least no hassle and nothing gets vanished.

jyavenard commented 3 years ago

Can I close this issue then?

Alright, I attempted to do it again. it turned badly anyway. I found all these missing sensors. I was able to rename these not missing back to what they were. Then, I found these "missing" ones lost their unique ID and as such they can't be modified in UI. Previous integration gave unique IDs to all. I like idea of this integration but if someone believes removing IDs was good idea, then I will be better of running REST instead. At least no hassle and nothing gets vanished.

Unfortunately, this was forced by the HA author who believe they should be modified from the iota watt directly. He's the one who made that change despite Greg's opposition

This HACS version adds new feature such as high resolution energy reads (so you can use them with the energy screen). But is otherwise identical to the one found now in HA.

That way you can switch between the HA one and the HACS one without having to rename anything.

What I will try to do is see if I can simulate a unique_id for output (which is what is needed to allow to rename them) but done in such a way that it will be compatible with the internal HA naming, so that it won't require to rename everything everywhere which takes forever.

darek-margas commented 3 years ago

What I will try to do is see if I can simulate a unique_id for output (which is what is needed to allow to rename them) but done in such a way that it will be compatible with the internal HA naming, so that it won't require to rename everything everywhere which takes forever.

Sensors from 0.8.0 had it as I was able to edit.

jyavenard commented 3 years ago

Sensors from 0.8.0 had it as I was able to edit.

Being able to make it editable is trivial. Make it in such a way that you don’t have to edit your entire setup because the internal name changed is another.

For now the HA people have decided that it shouldn’t be editable and instead you should rename it on the iotawatt itself. It was a very shortsighted approach particularly because doing it that way will cause to lose all your history

darek-margas commented 2 years ago

Definitely works now. Any hope for that version to be in core?

jyavenard commented 2 years ago

Definitely works now. Any hope for that version to be in core?

The latest changed for merged in HA earlier today. But still no editable output.

mmiller7 commented 1 year ago

I found all these missing sensors.

Can you elaborate how?

I somehow am missing all mine after a recent update and I don't know why or how to fix it.