UPB Lighting Controls - old

So this is only one-way, but it’s better than nothing. As a noobie to hass, this took a long time to figure out. I’m guessing the techniques here can be used in other ways as well.

Tools needed:

configuration.yaml:

input_slider:
  light_office_ceiling:
    min: 0
    max: 100
    step: 5
  light_bedmaster_ceiling:
    min: 0
    max: 100
    step: 5

automation:
  - alias: light_setlevel
    trigger:
      platform: state
      entity_id: 
        - input_slider.light_bedmaster_ceiling
        - input_slider.light_office_ceiling
    action:
      service: shell_command.upb_dim
      data_template:
        value: '{{ trigger.entity_id }} {{ trigger.to_state.state | int }}'

shell_command:
  upb_dim: '/opt/upb_scripts/upb_dim.sh {{ value }}'

upb_dim.sh:

#!/bin/bash

echo "$*" >> /tmp/upb_debug

# called with param like:  input_slider.light_office_ceiling 30

ROOM=`echo $1 | awk -F. '{print $2}'|awk -F_ '{print $2}'`
LIGHT=`echo $1 | awk -F. '{print $2}'|awk -F_ '{print $3}'`

ID=`cat /opt/upb_scripts/upb.upe |grep ^3|grep -i $ROOM|grep -i $LIGHT  | cut -d, -f2`

upb-cli -n 99 -i $ID -t device -c goto -l $2 --send -p /dev/ttyS1

Thanks to DaAwesomePA, @ih8gates, @farstreet and others who post constructive examples and help online.

3 Likes

Don’t do this thread.

A better way https://community.home-assistant.io/t/taking-a-crack-at-upb-platform-development/18924/20?u=bbrendon