#Card with text/icon only and dynamic colour

1 messages · Page 1 of 1 (latest)

hazy hamlet
#

I have a JSON file pulled from a remote source and when parsed will pull out some integer values. Not sure the best way to go about this as the cards seem very limited at the moment, and HACS requires github full account repo access (which I want to avoid).

  • Automation currently pulls JSON file
  • Condition then reads this and checks if a Var == 2 or 3 etc
  • I want the card text on the dashboard to be replaced with a status, and the background colour of this card changed, depending on this value
  • This process should be repeated for multiple similar cards
subtle onyx
#

It's not "full account repo access"

For authentication, an OAuth token with no scopes is used. It grants read-only access to public information (including user profile info, repository info, and gists).

Make a dummy account if you really care about it - doing something like this without any custom cards is really clunky

hazy hamlet
#

So private repos are secure from this authenticated account access?

subtle onyx
#

Yup, looking at the github scopes - no scope is public only, repo will include private repos

hazy hamlet
#

Sorry I didn't understand that. Granting HACS github access to my account was about updates and rate limits etc, makes sense. However HACS is getting access to the github account. So I assume that means sourcefile access to all my public repos, but does that also mean sourcefile access to my private repos?

hazy hamlet
#

Thanks for the link. So: yes/no ?

subtle onyx
#

No it has a scope of no scope - as that table shows you, you need at least a scope of repo to see anything private

hazy hamlet
#

Perfect, thank you

#

I assume my original question is far easier to do once HACS is installed

lethal oriole
#

Well for the original question it sounds like you want the rest integration

open ospreyBOT
hazy hamlet
#

Yep, I'm already using a restful_command to do my http request and pull a json value, and an hourly automation that runs this

subtle onyx
#

Aye, I'd look at custom button cards for something with a lot of control that can do exactly what you want, or mushroom cards if you want something a little more consistent with normal ha cards, but changing more than the icon colour is tricky

hazy hamlet
#

It's pretty much just running some actions when this automation fires, pulling some JSON values in a condition, and then running an update on dashboard widgets with the value and a colour change. That's all I'm looking for at the mo

indigo ermine
#

I want the card text on the dashboard to be replaced with a status, and the background colour of this card changed, depending on this value
As long as your variable is stored as an entity that the card can reference, you just need to pick out a card and do a basic set up of what you want the card to look like. We can help with the customization but you have to lay the groundwork for whatever you want to see.
As mentioned above, the custom:button-card will probably be your best bet particularly if you're wanting to create status messages and styling based on the state of the entity.
This process should be repeated for multiple similar cards
If you're going to have a bunch of these cards, another reason to consider the custom:button-card is because it has the ability to use configuration templates. This makes it super easy to repeat the design (and only have one place needing to make changes, if needed). For example, a series of cards I have looks like this: ```yaml
type: custom:button-card
template: door_animated
entity: binary_sensor.living_room_door_on_off
name: Living Room
variables:
var_battery_entity: sensor.living_room_door_battery_level

hazy hamlet
#

for example. In an hourly automation, I do an http request, and pull a JSON object with the following information:
{"var1":"1", "var2":"2", "var3":"3", "var4":"4"}
After taking the JSON, I use a conditional block if/then to output to the log "VAR1 ==1 true" or "VAR2==5 false", so it's reading these values correctly. However, I want some ui elements on the dashboard to reflect this value as it's a status code. For example, a card that changes background colour, or updates one text work, etc

hazy hamlet
#

Ok, I've actually solved this, for anyone else interested (bear in mind I'm new still to HA)

#
  • Settings >> Devices >> Helpers >> "Create Helper" >> Toggle (This can be used as a boolean variable)

  • Settings >> Automations >> New automation

  • Settings >> Automations >> WHEN: [Your desired trigger]

  • Settings >> Automations >> THEN DO: Add action Restful command

  • Settings >> Automations >> THEN DO: Add action If/Then

  • In condition: if {{ returnedjson.content.testval == "1" }}
  • Then: input boolean "Turn on" >> "Choose Entity" >> the boolean you made from earlier
#

Then in the dashboard UI you have your custom button toggle and make sure it's "disabled" so that you can't tap to change it. So it relies only on the input from the JSON.