Script i think is what i need but not sure how to implement

Hi All

BAck to basics for some i know, but cant get my head round it :slight_smile:

I want a virtual button (so to speak) which i can place on my HADashboard, i would like the button to send the following commands.

when on

command line onkyo zone2 power on
broadlink ir - send Ir command on

when off

command line onkyo zone2 power on
broadlink ir - send command off

these are obviously not the correct strings of command etc, but need to know how to code it just the basics if anyone could help?

thanks

Do you have a way to monitor whether either of these devices are on or off? If so your easiest option would be a template switch.

If not there’s a few options depending on what suits your setup best, but I won’t list them all until we know the answer :slight_smile:

cheers for reply,

i’m not to fussed about the status as when on the commands will be both on commands, and when switching off, it will be an off command. So i guess if one as been turned off by other means, the on command will no no difference, and if its still on the the on command wont turn it off, if that makes sense?

I’m not sure i can get the status via the onkyo command line, but probably possible. and only just starting out with the broadlink IR, i know my old Sony AV amp has 2 way IR, but not sure if the broadlink has?

I’m just trying to make things a bit easier for ‘her in doors’ :slight_smile: and still at the early stages, even though been a user of HA for a couple of years, i’ve only just got round to improving everything. Always had the basic lights on/off, and cam feeds.

Essentially Power up Zone2 for the nuresery room, she can then select another button to choose CD player, Echo, or mopidy audio once the zone 2 is powered up. All my amps etc are in one cupboard, so tablet on the wall is best bet for her.

Thanks

OK, the simplest way (I can think of atm) for that will be to use an input_boolean and an automation that triggers when the input_boolean changes state:

input_boolean:
  wife_acceptable_switch:
    name: Wife acceptable switch
    icon: mdi:power

automation:
  alias: Switching things from wife switch
  initial_state: on
  trigger:
    platform: state 
    entity_id: input_boolean.wife_acceptable_switch
  action:
    service_template: >
      {% if is_state('input_boolean.wife_acceptable_switch' , 'on') %}
        homeassistant.turn_on
      {% else %} homeassistant.turn_off {% endif %}
    entity_id:
      - COMMAND LINE SWITCH FOR ONKYO
      - IR SWITCH FOR TV

thank you for the detailed reply. I will give it a go later today and see how i get on.

Regards

1 Like