Giter Site home page Giter Site logo

Comments (25)

cyberjunky avatar cyberjunky commented on September 15, 2024 1

@bramstrokersorry, was a bit busy with other stuff, will have a look tomorrow morning and post here...

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024 1

Thanks for the useful information. Pretty sure I will be able to reproduce this now.
Not sure when I can have another look. Maybe I can find some time tomorrow. Will keep you updated.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

see #108. please try my suggestion and see if this helps. I think this lines can be safely removed, but I need to do some further testing.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Unfortunately I am unable to reproduce this issue.
I have setup a input boolean, and customized the friendly name:

sensor:
  - platform: powercalc
    entity_id: input_boolean.friendlyname_test
    fixed:
      power: 50

input_boolean:
  friendlyname_test:
    name: friendlyname test

homeassistant:
  customize:
    input_boolean.friendlyname_test:
      friendly_name: "My friendly name"

Created entities look correct to me:
Screenshot 2021-08-23 at 22 13 12

See the powercalc energy entity in this screenshot on the bottom:
Screenshot 2021-08-23 at 22 12 41

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

@bramstroker this is exactly what I mean.
With this config you would expect that "friendlyname test energy" is called "My friendly name energy"
This is the case if you don't have a global "powercalc:" section in the config, with it you get this behavior.
At least that's what I see here, I maybe have overlooked something obvious though.

Btw it would also be nice if the global naming template "Verbruik {}" would work on friendly name instead of raw device name.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

See #116 for the work in progress. Not sure if this changes has unwanted side effects. So need extensive testing before releasing to the public.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Just did a lot of cleanups and refactoring and issued first beta. v0.5.0-beta.1.
Are you able to test with this version and let me know your findings?

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

Yes will do and let you know, thanks!

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

@cyberjunky Were you already able to do some testing?

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

I don't think it fixes this problem.
It worked one time, but not consistent, no idea what is going on yet.
So with a global section powercalc: with only refresh rate you look friendly names of all sensors
Also entity_naming "{} verbruik" works
But "Verbruik {}" is not allowed (invalid config)

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

@cyberjunky
I need some more information to get a grip of what's going on.
Which exact version of powercalc are you testing now?
There should be no difference when you have global section powercalc enabled or not.

Could you please enable debug logging?
Than share you configuration, the logs after starting home assistant and maybe a screenshot of the entities created by Powercalc.
It will also make things easier when you comment out all powercalc sensors except one.

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

yeah I know, and will do, I write components myself and know how frustrating it is hen people don't give info, this was just a heads up that something strange is going on.
But I can 100% reproduce the powercalc: issue if you only specify the scan_interval.

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

I'm running 0.5.0-beta2
Unpacked the zip inside custom_components/powercalc/

Scenario #1
This config:

homeassistant:
  customize:
    sensor.system_fritzrepeater:
      friendly_name: "FRITZ!Repeater"
      icon: mdi:router-wireless

sensor:
  - platform: powercalc
    entity_id: sensor.system_fritzrepeater
    fixed:
      power: 5.5

Developer view sensor.system_fritzrepeater attributes:

state_class: measurement
last_reset: '2021-08-23T08:36:50.587227+00:00'
source: sensor.fritz_repeater_power
source_entity: sensor.system_fritzrepeater
source_domain: sensor
unit_of_measurement: kWh
friendly_name: FRITZ!Repeater energy
icon: mdi:lightning-bolt
device_class: energy

Log:

2021-08-28 14:17:15 DEBUG (MainThread) [custom_components.powercalc.sensor] Setting up power sensor. entity_id:sensor.system_fritzrepeater sensor_name:FRITZ!Repeater power strategy=FixedStrategy manufacturer= model= standby_usage=None
2021-08-28 14:17:15 DEBUG (MainThread) [custom_components.powercalc.sensor] Creating energy sensor: FRITZ!Repeater energy
...
2021-08-28 14:17:24 DEBUG (MainThread) [custom_components.powercalc.sensor] State changed to "Online" for entity "sensor.system_fritzrepeater". Power:5.5

So friendly_name is fine! All good.

Scenario #2:
This config (i want a scan_interval of 1min) rest same as above:

homeassistant:
  customize:
    sensor.system_fritzrepeater:
      friendly_name: "FRITZ!Repeater"
      icon: mdi:router-wireless

powercalc:
  scan_interval: 00:01:00

sensor:
  - platform: powercalc
    entity_id: sensor.system_fritzrepeater
    fixed:
      power: 5.5

Developer view sensor.system_fritzrepeater attributes:

state_class: measurement
last_reset: '2021-08-23T09:32:38.588985+00:00'
source: sensor.system_fritzrepeater_power
source_entity: sensor.system_fritzrepeater
source_domain: sensor
unit_of_measurement: kWh
friendly_name: system fritzrepeater energy
icon: mdi:lightning-bolt
device_class: energy

Log:

2021-08-28 14:26:12 DEBUG (MainThread) [custom_components.powercalc.sensor] Setting up power sensor. entity_id:sensor.system_fritzrepeater sensor_name:system fritzrepeater power strategy=FixedStrategy manufacturer= model= standby_usage=None
2021-08-28 14:26:12 DEBUG (MainThread) [custom_components.powercalc.sensor] Creating energy sensor: system fritzrepeater energy
..
2021-08-28 14:26:16 DEBUG (MainThread) [custom_components.powercalc.sensor] State changed to "Online" for entity "sensor.system_fritzrepeater". Power:5.5

So you see it now creates the energy sensor without the friendly name.
You have to be able to reproduce this with this info.

I will address the energy_nameing config issue in a separate issue.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

@cyberjunky you are sure you are using the beta version 0.5.0-beta.1 of 0.5.0-beta.2?
Fixes are not in master yet.

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

in custom_components
i did wget https://github.com/bramstroker/homeassistant-powercalc/releases/download/v0.5.0-beta.2/powercalc.zip
mkdir powercalc
cd powercalc
unzip ../powercalc.zip
and rebooted

image

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Unfortunately I am unable to reproduce yet.
The friendly name of the source entity sensor.system_fritzrepeated is retrieved from the state machine of Home Assistant. In your case the state of the entity was not available and powercalc will fall back to extract the name from the entity_id.
When the integration which created sensor.system_fritzrepeated was not loaded before powercalc plartform, the state can not be retrieved, so that would potentially be the problem.
Which integration did create sensor.system_fritzrepeated?

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

Wait, this could be the cause, those are template sensors from device_trackers to translate home/away to on/off or online/offline.

sensor:
  - platform: template
    sensors:
      system_laptopwerk:
        value_template: "{{ 'on' if is_state('device_tracker.laptopwerk', 'home') else 'off' }}"
      system_printerlj3600:
        value_template: "{{ 'on' if is_state('device_tracker.printerlj3600', 'home') else 'off' }}"
      system_fritzbox:
        value_template: "{{ 'Online' if is_state('device_tracker.fritzbox', 'home') else 'Offline' }}"
      system_fritzrepeater:
        value_template: "{{ 'Online' if is_state('device_tracker.fritzrepeater', 'home') else 'Offline' }}"

I read that you support device_trackers directly now I think correct?

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Yes device trackers are directly supported. Only in beta version yet.
For the template sensor to work could you please try adding template to manifest.json dependencies?

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

Yes this fixed the issue, great!

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Yeah! I will incoorporate the fix in the next beta.

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Just released v0.5.0-beta.3. Could you do a final check if everything works for you in this version? Than we can close this issue.

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

I downloaded the 0.5.0-beta3 zip

It doesn't work, it seems you forgot to insert the dependency for template?

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

Made a mistake. Did create the beta releases from wrong branch master. Removed the releases and created new one from beta now v0.5.0-beta.3, which also includes the fix for #145

from homeassistant-powercalc.

cyberjunky avatar cyberjunky commented on September 15, 2024

Yes working like a charm, the regex and template issue solved, thanks alot, you save me code something like this!

image

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 15, 2024

cool! Closing this issue now. all these changes will be available in v0.5.0

from homeassistant-powercalc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.