UPB lighting

I suggest the integration offer a means of dynamically changing the port and UPE file name (the HACS integration exposes this functionality with an Options button).

Otherwise, this can happen:

  • To change the file name or port, you uninstall and reinstall the UPB integration.
  • Upon re-installation, a new device_id is assigned.
  • As a consequence, any existing Device Automations are broken.

All the PRs for the UPB integration have been accepted.

The doc page is here: https://github.com/home-assistant/home-assistant.io/blob/2a6fb864c8e6c40eb3f2ac8ff1834d1a1919da80/source/_integrations/upb.markdown

This should arrive in 0.110.

2 Likes

First question, have the docs overlooked to describe upb.scene_activate or has this service been eliminated?

Second question, should the integration standardize its terminology for UPB link/scene?

Traditionally itā€™s called a link but, as seen in UPStart, that term morphed to scene.

The integrationā€™s services use the term scene exclusively:

  • upb.scene_deactivate
  • upb.scene_goto
  • upb.scene_fade_start
  • upb.scene_fade_stop
  • upb.scene_blink

However, the event uses the term link:

  • upb.link_changed

Should one term be used consistently in both the event and service or is there an advantage to use different terms?

If the choice is consistency, should it be upb.scene_changed or should all services use link (i.e. link_goto, link_deactivate, etc)?

upb.scene_activate was removed in favor of scene.activate. i.e.: use what exists and donā€™t create extra services.

Good point on scene_* vs link_* consistency. I have no preference on either name. Perhaps see what other integrations are doing with naming and follow that example?

Now Iā€™m confused. Where is that service documented?

If I look in sceneā€™s services.yaml, I see scene.turn_on but no mention of scene.activate:

Is it a new scene service that will appear in the 0.110 release?


FWIW, my vote is for standardizing on the term scene (i.e. upb.scene_changed) but, if others strongly disagree and in the interests of avoiding a breaking change, I can live with the existing upb.link_changed.

Meant scene.turn_on. The code, for whatever reason uses activate as the method.

Iā€™m ok to change event name, not breaking yet since code not released.

Ah, OK! It interesting to learn that the term used internally actually does a better job of describing the action (scene is activated, not ā€˜turned onā€™).

If you want, I can compose a few examples (including one that uses scene.turn_on) for inclusion in the docs.

1 Like

FYI, in the documentationā€™s description of Events, thereā€™s a typo on the last line. It misspells the word transition.

rate : The rate for link to transition to the new level. rate is -1 for the default transiton rate.

Here are the promised examples. Please review them to ensure they comply with the new events and services (I donā€™t currently have the means of testing the latest version of the integration). Iā€™ve taken the liberty of renaming link_changed to scene_changed.

#automation:

- alias: 'Specific scene activated'
  description: 'Trigger when scene 9 on network 42 is activated'
  trigger:
    platform: event
    event_type: upb.scene_changed
    event_data:
      command: activated
      address: '42_9'
  action:
    service: persistent_notification.create
    data_template:
      message: 'Scene 9 on network 42 was just activated: {{trigger.event.data.command}}, {{trigger.event.data.address}}'
      title: 'Scene Activated'
#script:
 
all_lights_on:
  alias: 'All Lights On'
  description: 'Activate two UPB scenes named interior_lights and exterior_lights'
  sequence:
    - service: scene.turn_on
      entity_id: 
        - scene.interior_lights
        - scene.exterior_lights

all_lights_off:
  alias: 'All Lights Off'
  description: 'Deactivate two UPB scenes named interior_lights and exterior_lights'
  sequence:
    - service: upb.scene_deactivate
      entity_id: 
        - scene.interior_lights
        - scene.exterior_lights

kitchen_fade_on:
  alias: 'Kitchen Fade to On'
  description: 'Turn on kitchen light to 75% over a period of 10 seconds'
  sequence:
    - service: upb.light_fade_start
      data:
        entity_id: light.kitchen
        brightness_pct: 75
        rate: 10

Should the docs also mention the use of homeassistant.update_entity?

1 Like

Excellent. I suggest that you create the doc PR. I will change the code. We will need to reference each others PRs in our PR. Here is how you will be able to find mine: https://github.com/home-assistant/core/pulls?q=is%3Apr+author%3Agwww (it includes all PRs by me, not just open). If you reference my github handle in your PR (@gwww) I will receive a notification.

Iā€™m going to need help with that. I donā€™t know where to begin.

For existing documentation, the page contains a link to ā€˜Edit this pageā€™ which starts you off on the process. In this case, the documentation is in your PR and I donā€™t know how to amend it. I see a pencil icon; I canā€™t click it but hovering over it indicates ā€œYou must be on a branch to make or propose changes to this fileā€.

Do I simply create a new PR, copy-paste your documentation, modify it, then submit it?

https://help.github.com/en/enterprise/2.14/user/articles/editing-files-in-your-repository

Assumes you have github account. But thatā€™s easy to get.

I have a GitHub account, Iā€™m signed it, and the linked instructions describe the pencil icon that I reported I am unable to click in your PR.

Iā€™m a complete novice with GitHub but I think I need to make a local copy of your repository and then edit that? git pull or git clone or something like that??

Yah, I would not get you into git clone, etc.

Were you clicking the pencil on https://github.com/home-assistant/home-assistant.io/blob/77743e84585335f2b1ecdae445bce33f57886347/source/_integrations/upb.markdown page? That allows you to edit. It also has a preview tab so that you can see that everything looks good.

Ah-hah! No! I was clicking on the original documentation link you shared several posts ago. I can click on the pencil icon in the latest link you posted. However, now Iā€™ve run out of time and will have to revisit it later this evening. :man_facepalming:

I now have register dumping and basic decoding working in pulse mode.

If you want to try it out:

python3 -m pip install upb
python3 -m upb.tools.dumpreg --host=192.168.1.32 --network=1 --device=5

Gives response(this is only a decode of the first 16 register bytes but adding the others is basically the same and I have the full register map from upstart):

registers: {'firmware_major_version': 1,
 'firmware_minor_version': 8,
 'manufacturer_id': 4,
 'module_id': 5,
 'net_id': 1,
 'password': 0,
 'product_id': 29,
 'serial_number': 0,
 'upb_options': 0,
 'upb_version': 1}

Iā€™ve uploaded the library code here, itā€™s super rough right now and will need to undergo some major refactoring rounds but Iā€™ve got enough of the basics working that it should be fairly straight forward(although somewhat time consuming) to fill out the missing features at this point.

@gwww I looked at basing this off of your library codebase and while I used it as a reference for some of the encoding/decoding the protocol handler is quite a bit different due to mine operating exclusively in pulse mode instead of message mode. Mine also provides a await def abstraction over protocol commands such as register requests which allows for a much easier to follow control flow and cleaner home-assistant integration.

1 Like

I wasnā€™t able to work on it last night and this morning the latest link you posted no longer allows me to edit the document (pencil icon is grayed-out):

Screenshot from 2020-05-14 10-38-39

Is the modifiable version of the document now in another ā€œtreeā€? How can I find it?

This should work: https://github.com/home-assistant/home-assistant.io/blob/526322243a71215bf03779721212819f1ee0064b/source/_integrations/upb.markdown (last one was wrong branch).

OK, thank. Just to confirm, after editing it Iā€™ll need to create a PR afterwards. In that PR I need to reference your GitHub moniker so youā€™ll be notified. Is that correct?

Done: PR 13445. My first ever so itā€™s undoubtedly flawed in some way.

My comment was prescient. The merge was blocked because, according to the bot, I targeted the wrong branch. Now itā€™s blocked and Iā€™m requested to change the branch to current and rebase it if necessary. I have no idea what that means let alone how to do it. Iā€™ll need your assistance once again.

Give the comment on the code PR, I suggest we back off the event name change for now. Just submit the new docs that increase their quality and we can revisit the naming at a later time.