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

Entity id for sensors within HA changes when updating name in web-ui #758

Closed
tp1de opened this issue Nov 20, 2022 · 7 comments
Closed

Entity id for sensors within HA changes when updating name in web-ui #758

tp1de opened this issue Nov 20, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@tp1de
Copy link
Contributor

tp1de commented Nov 20, 2022

I recognized that while changing names for sensors (analog & dallas) within web-ui the entity id changes as well for HA.
I think only full name should change. Entity id should be kept.

@tp1de tp1de added the bug Something isn't working label Nov 20, 2022
@proddy
Copy link
Contributor

proddy commented Nov 20, 2022

I did a quick test with Analog sensors, and you're correct, when you create one (say GPIO 31, name is Analog1) it will create the HA entity called sensor.analog_sensor_analog1. I think it's best to use the GPIO and not the name, so sensor.analog_sensor_31

Same with Dallas temperature sensors. It will also use the name, e.g. sensor.temperature_sensor_zolder. Shall we change this to use the unique dallas ID, so sensor.temperature_sensor_28-233D-9497-0C03. We may need to convert the dashes to underscores as I know HA can be picky about that.

@proddy proddy added enhancement New feature or request and removed bug Something isn't working labels Nov 20, 2022
@proddy proddy added this to the v3.5.0 milestone Nov 20, 2022
@proddy proddy self-assigned this Nov 20, 2022
@tp1de
Copy link
Contributor Author

tp1de commented Nov 20, 2022

I think it is important to keep the unique id in ha when updating names within ems-esp to keep history in statistics as well the dashboard configuration. I haven't recognized issues with dashes within unique id. I would keep it. For analog sensor I would recommend to add gpio to the name ... e.g. sensor.analog_gpio_31 .... two times "sensor" ist not needed.

@tp1de
Copy link
Contributor Author

tp1de commented Nov 20, 2022

... and for dallas the "value" in api seems to be rounded to full integer.

{
"id": "28-FF04-CFC4-1604",
"name": "Dallas 1",
"value": 24,
"type": "number",
"min": -55,
"max": 125,
"uom": "°C",
"writeable": false
}

/api/dallassensor:
{
"Dallas 1": {
"id": "28-FF04-CFC4-1604",
"temp": 24.1
},
"28-FF3B-04C5-1604": {
"id": "28-FF3B-04C5-1604",
"temp": 25.6
}
}

@proddy
Copy link
Contributor

proddy commented Nov 20, 2022

... and for dallas the "value" in api seems to be rounded to full integer.

can you create a new issue for this please. It's a new bug, and not related to HA

@tp1de
Copy link
Contributor Author

tp1de commented Nov 20, 2022

... the whole issue is related to ha as well to api. Api responses for dallas and analog sensors are different anyhow.

@MichaelDvP
Copy link
Contributor

Yes dallas and anlog api is not in line with devices.
I suggest to use the info/values command only for a list

call dallassensor values
{
  "cylinder_top": 45.3,
  "solar_flow": 23.2,
  "cylinder_middle": 33.9,
  "cylinder_bottom": 21.8,
  "circ_backflow": 34.1,
  "solar_backflow": 22.6,
  "boiler_backflow": 40.6
}

and add the value info with name,

call dallassensor cylinder_top
{
  "id": "28-7284-131F-1901",
  "name": "cylinder_top",
  "value": 45.3,
  "type": "number",
  "uom": "°C",
  "writeable": false
}

For HA the info should change the object_id to from name to id also matching the topic.
( actual: "object_id": "temperature_sensor_cylinder_top",)

homeassistent/sensor/ems-esp/dallassensor_28-7284-131F-1901:
{
  "dev_cla": "temperature",
  "stat_t": "ems/dallassensor_data",
  "unit_of_meas": "°C",
  "val_tpl": "{{value_json['cylinder_top']}}",
  "object_id": "temperature_sensor_28-7284-131F-1901",
  "name": "cylinder_top",
  "uniq_id": "dallasensor_28-7284-131F-1901",
  "dev": {
    "ids": [
      "ems-esp"
    ]
  }
}

same scheme for analogs, the id is there the gpio.

call analogsensor values
{
  "pressure": 1.185,
  "test": 0.01
}
call analogsensor pressure
{
  "gpio": 36,
  "name": "pressure",
  "type": "number",
  "analog": "adc",
  "uom": "bar",
  "offset": 500,
  "factor": 0.003,
  "value": 1.185,
  "writeable": false
}

HA config with object_id containing gpio:

homeassistent/sensor/ems-esp/analogsensor_36:
{
  "stat_t": "ems/analogsensor_data",
  "val_tpl": "{{value_json['pressure']}",
  "object_id": "analog_36",
  "name": "pressure",
  "uniq_id": "analogsensor_36",
  "unit_of_meas": "bar",
  "dev": {
    "ids": [
      "ems-esp"
    ]
  }
}

For digital_out we should also add a command, now we have analogsensor/setvalue {"value": true, "id": 38} for setting gpio 38, we should also register command with name, e.g. extra_pump
analogsensor/extra_pump {"value": true}

@proddy
Copy link
Contributor

proddy commented Nov 28, 2022

tested it and works great in HA

@proddy proddy closed this as completed Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants