home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.28k stars 30.6k forks source link

A counter name with underscore does not work #39927

Closed 1nordlicht closed 3 years ago

1nordlicht commented 4 years ago

I started to use a counter with this name:

counter:
  gas_counter:
    step: 1

While using an incrementation of this counter name, I detected that it does not work.

action:
  - data: {}
    entity_id: counter.gas_counter
    service: counter.increment

After changing the counter name and removing the underscore from it's name, the counter is working fine:

counter:
  gascounter:
    step: 1

Nothing else has been changed, just the counter name. I'm running Home assistant supervised on raspbian.

spacegaier commented 4 years ago

Which version of HA are you running? I cannot reproduce the issue in the latest dev version. Both my test counters counter.gascounter and counter.gas_counter increment just fine.

Do you see any errors in the log?

1nordlicht commented 4 years ago

0.114.4 and Supervisor 242

I was not able to see errors. Which log is the good one for this?

spacegaier commented 4 years ago

In your home-assistant.log. Perhaps also increase your debug level of the logger. Perhaps that yields more insights.

1nordlicht commented 4 years ago
2020-09-11 09:26:42 ERROR (MainThread) [homeassistant.components.hassio] Component error: counter1 - Integration 'counter1' not found.
2020-09-11 09:32:22 ERROR (MainThread) [homeassistant.components.automation.gasmonitor] Gasmonitor: Error executing script. Service not found for call_service at pos 2: Unable to find service counter1/increment
2020-09-11 09:32:22 ERROR (MainThread) [homeassistant.components.automation.gasmonitor] While executing automation automation.gasmonitor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 430, in async_trigger
    await self.action_script.async_run(variables, trigger_context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 802, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 183, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 380, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service counter1/increment
probot-home-assistant[bot] commented 4 years ago

counter documentation counter source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @fabaff, mind taking a look at this issue as its been labeled with an integration (counter) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

spacegaier commented 4 years ago

Based on the log your configuration is incorrect. It seems your configuration is attempting to call a service that does not exist. Can you search in your configuration and automation YAML files for "counter1".

fabaff commented 3 years ago

Works for me on dev as well.

counter:
  gas_counter:
    step: 1
  gascounter:
    step: 1
UlrichMai commented 3 years ago

I was going thru the same pain as @1nordlicht with version core-2021.8.8. The increment did not work. I changed the name from "gas_counter" to "gascounter" and the counter behaved normal. Then I tried to dig into that, changed the name back to "gas_counter" and set the logger level of the counter component to debug, but the counter behaved normal. There is definitely a problem with the underscore being used in your first counter ever in the system.