almost all my buttons have the same styling. It would be very good to centralize the styling so if i want to change something up i dont have to apply it to every card seperate. Especially grid layout and stuff is annoying.
Basically just follow the ReadMe of button card. If you can post your code of your button, I can help you with creating it as a template so you can copy/paste.
Hi, I have a button card that I want to turn into a toggle button that will trigger a Harmony activity, I’m wondering if anyone can help me with?
This is my current config:
The button is always on, because there is no entity defined to check the state on. If you have a way to see if your Switch is on, you can use that as an entity so the button can change depending on the state. I believe the Switch has no API’s etc to really integrate it to HA. If that’s the case, you can try to emulate it some way.
There a different ways you can do this, I personally use input booleans. You can create a virtual entity basically that way, then you use that as a trigger for your Harmony automation. I suggest you read about input boolean to see what the benefits are and how to use them.
This is what you can setup for instance: you can create an input boolean (which is basically a virtual switch (as in button, not Nintendo Switch, the word switch is confusing in this context lol). You can create an automation so when you turn the input boolean state to on, your Harmony automation will trigger. And also create an automation that will trigger when you turn the input boolean state to off (for instance turn of your Switch via Harmony, if that’s possible).
If you tie the input boolean as an entity to the custom button card (so use the entity variable as mentioned in the ReadMe), it will use the state of that entity. So when you turn it on (and trigger your automation), the button card will use the ‘on’ state. In that case you don’t need to use call-service in custom button (since you created an automation withing HA already with the input boolean as a trigger). You can then just use action: toggle
tap_action:
action: toggle
That way you can turn the input boolean on and off by pressing the button, which will trigger your automations turning on the Switch or turning it off. Which will then be used by button card to show the state of the automation to on or off.
Just replace playstation 4 to fit your needs. go into dev settings or the harmony_config file to look which activites you have set up.
and then lovelace. you dont need tap action btw if you just want to use a toggle.
- entity: switch.ps4
.... whatever you want
type: 'custom:button-card'
Check out this thread for more harmony home assistant stuff.
Just out of curiosity, why don’t use the PS4 integration for the remote functions? I don’t use Harmony myself but I have setup my PS4 with the official integration. Works like charm, shows the state of PS4 (standby, playing), which game is playing (is displayed as a media_player) and has remote service. You can even launch games directly with input select. I have automations setup where the PS4 will turn on and where other automations will trigger depending on the state of PS4.
I want to turn on the ps4 with the harmony remote control. The Harmony System is activity based, every activity turns on the correct channel etc and sends the command directly via ir or bt to your tv, avr, beamer, firetv stick, ps4… so your devices dont have to have things like cec, arc, or a home assistant network integration (that are sometimes unreliable). You can control everything with one remote, as long as your device has ir or bt. You can even interrupt button presses with Home Assistant and the emulated roku integration which is quite nice as you can remap every button on the harmony remote to do whatever you want.
I use the PS4 integration too. If the ps4 template switch turns on my ps4 turns on via the ps4 integration and the other way around.
I used Harmony a few years ago a lot. But ever since I stepped in to home automation, I didn’t see any need for it anymore since I can hook up IR etc with home automation platforms as well. Though I do know that Harmony’s activity setup is solid, I don’t like using IR that much (especially with turning devices on/off or when it’s not in sync). Or when trying to read the state of the device consistently (like what HDMI port the soundbar is on etc). Perhaps if you strictly use Harmony and template sensors, you can solve those issues. Might try it again in the future to have one central way of controlling media (and not be dependable of custom integrations with broken support etc).
Edit: damnit, I just ordered myself a Harmony Hub to see experiment with it. Why must you tempt me?? lol
Right, then you should be able to use a custom_field to achieve this and have this custom field replace the current icon in the grid.
If you put everything that you have in style: | from your markdown card in a custom_field, that should be a starting point and then adapt it using javascript templates to do what you want with it
Thanks for putting me in the right direction, I’ll try as soon as I get home:+1:
PS
I take this opportunity to tell you that this card is complex but the most complete👍
I have tried to “close” my climate card n a button card for my dashboard:
The result is interesting, it is working on PC with the mouse but doesn’t work with touching either windows and android.
Is there any solution for the touch working?