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

Lametric component sound problem and cycles feature request #10561

Closed
frittes opened this issue Nov 13, 2017 · 19 comments · Fixed by #10562
Closed

Lametric component sound problem and cycles feature request #10561

frittes opened this issue Nov 13, 2017 · 19 comments · Fixed by #10562

Comments

@frittes
Copy link
Contributor

frittes commented Nov 13, 2017

Home Assistant release (hass --version):

0.57.3

Python release (python3 --version):

Python 3.5.2

Component/platform:

https://home-assistant.io/components/notify.lametric/

Description of problem:

Notification sound does not work.

Additional info:

Added

sound: notification

to /home/homeassistant/.homeassistant/notify.yaml

- name: lametric1
  platform: lametric
  display_time: 20
  icon: a7956
  sound: notification

and component stops working.

In the code (lametric.py), the sound is added to the list of frames. And the list of frames is added to the model.

I think the sound has to be added to the model.

See:

https://github.com/keans/lmnotify/blob/master/lmnotify/models.py

and

http://lametric-documentation.readthedocs.io/en/latest/reference-docs/device-notifications.html

notify/lametric.py

        frames = [text_frame]

        if sound is not None:
            frames.append(sound)

        _LOGGER.debug(frames)

        model = Model(frames=frames)

If sound is added to the list of frames, component stops working.

It would be nice, if cycles were also implemented. At the moment, the notification is displayed once, also if display_time is set to 20 seconds. If cycle are configurable, the notification could be shown maybe 3 times or 0 for static.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Nov 13, 2017

Does the display_time option work? If display_time is set to 20 seconds, the notification is shown for 20 seconds?

@frittes
Copy link
Contributor Author

frittes commented Nov 13, 2017

No. The notification is only displayed once.

On the lametric site, the lifetime should be in milliseconds. In HA is in seconds.

@MartinHjelmare
Copy link
Member

So nothing changes if you change the display_time option? Should we remove that option then?

@frittes
Copy link
Contributor Author

frittes commented Nov 13, 2017

Let me try in milliseconds.

@frittes
Copy link
Contributor Author

frittes commented Nov 13, 2017

It makes 20000000 in the log, the recalculate works. :D No, if it is set to 20 seconds in the config, the notification is showed once. It is about 6 seconds.

From lametric site for lifetime:

The time notification lives in queue to be displayed in milliseconds. Default lifetime is 2 minutes. If notification stayed in queue for longer than lifetime milliseconds – it will not be displayed.

It is not the time to display. It defaults to 2 minutes. I think it is useless.

@MartinHjelmare
Copy link
Member

Thanks for this info. I think we should keep it to not make a breaking change, but we should document it properly with the info above.

I'll try to add cycles. Should it be a configuration option or service data option?

@frittes
Copy link
Contributor Author

frittes commented Nov 13, 2017

For my opinion it should be a configuration option. It lets the user choose how often a message repeats.

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

@MartinHjelmare The service call from the dev console works, but if I add the sound to the automation, it does not work.

`2017-11-14 20:25:36 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=140511511142072-84, domain=notify, service=lametric1, service_data=sound=bicycle, message=Lennart ist unterwegs.>
2017-11-14 20:25:36 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 140510057829264: Sending {'id': 2, 'type': 'event', 'event': {'time_fired': datetime.datetime(2017, 11, 14, 19, 25, 36, 424787, tzinfo=), 'event_type': 'state_changed', 'origin': 'LOCAL', 'data': {'new_state': <state device_tracker.lennart_iphone=not_home; longitude=XXXXX, friendly_name=Lennart, battery=100, tid=LE, entity_picture=/local/images/lennart_neu.png, latitude=XXXXX, source_type=gps, gps_accuracy=65 @ 2017-11-14T20:25:36.424747+01:00>, 'entity_id': 'device_tracker.lennart_iphone', 'old_state': <state device_tracker.lennart_iphone=home; longitude=XXXXX, friendly_name=Lennart, battery=100, tid=LE, entity_picture=/local/images/lennart_neu.png, latitude=XXXXX, source_type=gps, gps_accuracy=65 @ 2017-11-14T20:23:05.278210+01:00>}}}
2017-11-14 20:25:36 ERROR (MainThread) [homeassistant.core] Invalid service data for notify.lametric1: extra keys not allowed @ data['sound']. Got 'bicycle'

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

@MartinHjelmare Automation rule is the right place, isn't it?

I think, the best way would be, to make the definition of the sound in the config (notify.yaml or configuration.yaml)). One sound for all messages to lametric. Otherwise you have to add the sound to every notification and in my opinion there is no need to make different sounds for notifications on lametric from HA.

@MartinHjelmare
Copy link
Member

I think we should keep the sound in the service call. That is the most flexible.

Can you post your automation? I think you're missing the data key in the service data. It's easier to test service calls in the developer tools service tab in the frontend. There you write json instead of yaml though.

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

This is my automation rule:

- alias: 'Sende Nachricht beim Verlassen des Zuhauses von Lennart'
  trigger:
    platform: state
    entity_id: device_tracker.lennart_iphone
    from: 'home'
    to: 'not_home'
  action:
    service: notify.lametric1
    data:
      message: 'Lennart ist unterwegs.'
      sound: 'bicycle'

@MartinHjelmare
Copy link
Member

Try this:

- alias: 'Sende Nachricht beim Verlassen des Zuhauses von Lennart'
  trigger:
    platform: state
    entity_id: device_tracker.lennart_iphone
    from: 'home'
    to: 'not_home'
  action:
    service: notify.lametric1
    data:
      message: 'Lennart ist unterwegs.'
      data:
        sound: 'bicycle'

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

Failed config on config test.

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

My fault. With data...data...it works.

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

But it is another way like mentioned in the automation documentation of action. "You have to do it like this, but with lametric you have to go another way..."

Is it possible to make it like:

- alias: 'Sende Nachricht beim Verlassen des Zuhauses von Lennart'
  trigger:
    platform: state
    entity_id: device_tracker.lennart_iphone
    from: 'home'
    to: 'not_home'
  action:
    service: notify.lametric1
    data:
      message: 'Lennart ist unterwegs.'
      sound: 'bicycle'

For me it works, but usability?

@MartinHjelmare
Copy link
Member

No the data key under service data for notify component is made for non standard extra keys, eg sound in this case.

This is documented here:
https://home-assistant.io/components/notify/#service

@frittes
Copy link
Contributor Author

frittes commented Nov 14, 2017

Ok, then it has to be documented in the lametric component (Extended functionality).

bildschirmfoto 2017-11-14 um 22 18 42

Do we rock on with the cycles change?

@MartinHjelmare
Copy link
Member

Yeah, I'll try do something on the cycles. I'll ping you when I have something.

@frittes
Copy link
Contributor Author

frittes commented Nov 18, 2017

@MartinHjelmare Made it and created a pull request.

#10656

@home-assistant home-assistant locked and limited conversation to collaborators Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants