Is it possible to make a mode switch in HA (without Custom UI etc.)?
Or make an Input Select component, - rendered like buttons?
The point of this is to have one selected all the time, and the other options deselected. When another is selected, the others are deselected.
1 Like
metbril
(Robert 🇳🇱🇪🇺)
June 12, 2018, 6:42pm
2
You mean something like tiles?
Tiles custom state card for Home Assistant
[preview]
Download and more info at GitHub: https://github.com/c727/home-assistant-tiles
Known issues:
-remove/disable more-info-dialog in state and header card
-if the original entity is it the same view the browser scrolls to it after clicking a button
Yes. But native HA (no custom code)
I am a bit baffled that HA lacks some basic functionality. As the N00b I am…
metbril
(Robert 🇳🇱🇪🇺)
June 12, 2018, 8:20pm
4
Tomahawk:
some basic functionality
Well, that depends on your needs and expectations. I don’t miss tiles myself.
Other people have created custom UI and/or HA dashboard. You can always use these or develop your own code. That is the great thing about open source software.
You are absoIurly right. I second that. It’s a matter of opinion what basic functionality is.
I am impressed by this community and what they com up with!
So hopefully with time more functionality is implemented so one do not need several custom packages to maintain
What do you know…Shame on me!
This was easily done with standard Ha code. All smile!
4 Likes
dkvhin
(Vin)
July 8, 2018, 2:58pm
7
Hi @Tomahawk , can I know how did you manage to make this work ? if you could share your config would appreciate it.
Thank You
This code is a workaround since HA does not have “radio button list” options.
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio
#File:input boolean
####################################################
# HA MODES #
####################################################
ha_mode_home:
name: Home
icon: mdi:home-account
ha_mode_away:
name: Away
icon: mdi:walk
ha_mode_night:
name: Night
icon: mdi:weather-night
ha_mode_holiday:
name: Holiday
icon: mdi:airplane-takeoff
#File: Sensors
####################################################
# HA MODE SENSOR #
####################################################
- platform: template
sensors:
ha_mode:
friendly_name: 'HA Mode'
entity_id: input_boolean.ha_mode_home,
input_boolean.ha_mode_away,
input_boolean.ha_mode_holiday,
input_boolean.ha_mode_night
value_template: >-
{% if is_state('input_boolean.ha_mode_home', 'on') %}
home
{% elif is_state('input_boolean.ha_mode_away', 'on') %}
away
{% elif is_state('input_boolean.ha_mode_night', 'on') %}
night
{% elif is_state('input_boolean.ha_mode_holiday', 'on') %}
holiday
{% endif %}
icon_template: >-
{% if is_state('input_boolean.ha_mode_home', 'on') %}
mdi:home-account
{% elif is_state('input_boolean.ha_mode_away', 'on') %}
mdi:walk
{% elif is_state('input_boolean.ha_mode_night', 'on') %}
mdi:weather-night
{% elif is_state('input_boolean.ha_mode_holiday', 'on') %}
mdi:airplane-takeoff
{% endif %}
#File: Binary sensor
####################################################
# HA MODE SENSOR Display only #
####################################################
- platform: template
sensors:
ha_mode:
friendly_name: "HA Mode"
entity_id: sensor.ha_mode
value_template: >-
{{ is_state('sensor.ha_mode', 'home')
or is_state('sensor.ha_mode', 'away')
or is_state('sensor.ha_mode', 'night')
or is_state('sensor.ha_mode', 'holiday') }}
icon_template: >-
{% if is_state('sensor.ha_mode', 'home') %}
mdi:home-account
{% elif is_state('sensor.ha_mode', 'away') %}
mdi:walk
{% elif is_state('sensor.ha_mode', 'night') %}
mdi:weather-night
{% elif is_state('sensor.ha_mode', 'holiday') %}
mdi:airplane-takeoff
{% endif %}
#File: Automation
#######################################################################
# HA MODE SET SCENES #
#######################################################################
- alias: HA Mode set
trigger:
platform: state
entity_id: input_boolean.ha_mode_home,
input_boolean.ha_mode_away,
input_boolean.ha_mode_holiday,
input_boolean.ha_mode_night
to: 'on'
action:
- service: input_boolean.turn_off
data_template:
entity_id: >
{% set booleans = [ 'input_boolean.ha_mode_home', 'input_boolean.ha_mode_away', 'input_boolean.ha_mode_holiday', 'input_boolean.ha_mode_night' ] | reject('equalto', trigger.entity_id) %}
{{ booleans | list | join(', ') }}
5 Likes
dkvhin
(Vin)
July 9, 2018, 9:26am
9
@Tomahawk awesome, thank you I’m new with HA, this would help a lot.
metbril
(Robert 🇳🇱🇪🇺)
July 10, 2018, 7:46pm
10
I was testing your example (am actually using a ‘fork’), and noticed that you can switch off all input booleans. Which will render the sensor.ha_mode empty. This would mean an unknown mode.
Have you considered how to catch this? There are a few options:
leave it as it is
use the automation (or a second one) to force/set a default (‘home’)
if all booleans are ‘off’, then switch to ‘away’ if the last state was ‘home’, otherwise switch to ‘home’.
What do you think?
I decided to leave it as is.
A second automation setting a specific mode if all sensor are set to off would my choice.
And hope for the HA team to implement a radiobutton list with time.
metbril
(Robert 🇳🇱🇪🇺)
July 11, 2018, 4:35am
12
Tomahawk:
implement a radiobutton
The new Lovelace UI should be able to render an input select to a radio button, I guess.
hajo62
(Hajo)
January 1, 2019, 3:33pm
13
Tomahawk:
File: Binary sensor
Hi Tomahawk,
thanks for your code. I copied it into my beginners configuration. And I have several newbie questions:
Is there a way to order the icons (Day / Night / Away / Vacation)?
How could I get rid of the Automatiserung-Widget?
How could rename the widget “Boolsche Eingabe”? I have no idea where the name came from?
In your grop.yaml-file, order the list at your choice:
ha_mode:
name: Mode
control: hidden
entities:
- input_boolean.ha_mode_home
- input_boolean.ha_mode_away
- input_boolean.ha_mode_night
- input_boolean.ha_mode_holiday
In your grop.yaml-file, remove the entry. -automation.Automatiserung-Widget(?)
hajo62:
How could rename the widget “Boolsche Eingabe”? I have no idea where the name came from?
In your grop.yaml-file, add name: XYZ to your ha_mode:
ha_mode:
name: Mode
control: hidden
entities:
- input_boolean.ha_mode_home
- input_boolean.ha_mode_away
- input_boolean.ha_mode_night
- input_boolean.ha_mode_holiday
1 Like
hajo62
(Hajo)
January 1, 2019, 9:49pm
15
I do not have an entry for the automation-Widget in the group.yaml-file… But, with your hints I made 75% of my wished
After entering your group hints, I have two sensor in the header line listed, which I do not really understand.
If you have the default setup, I believe your automations and your sensors will show up by default in your GUI.
If you start organizing your group.yaml-file, with your own declared default view, you will have total control of what and how items are displayed.
#############################################################
# DEFAULT VIEW groups.yaml #
#############################################################
default_view:
name: Home
view: yes
icon: mdi:home
entities:
- binary_sensor.ha_mode
- sensor.moonphases
- sensor.weather_symbol_text
- sensor.weather_temp_feel
- sensor.weather_temperature
- sensor.weather_wind_speed
- sensor.wind_compass
- sensor.sunrise_today
- sensor.sundaylight_today
- sensor.sunset_today
- sensor.nilu_air_pollution_outside
- sensor.nilu_oslo_manglerud_max
- group.entre
- group.stue
- group.kjokken
- group.baderom
- group.soverom
- group.loft
loft:
name: Loft
entities:
- zwave.fib_smoke_sensor3
- sensor.fib_smoke_sensor3_temperature
- zwave._fib_flood_sensor1
- switch.switch_water_boiler
# - sensor.fib_flood_sensor1_temperature
etc..
#############################################################
# AUDIO/VIDE VIEW #
#############################################################
audio_video_view:
name: Audio/Video
view: yes
icon: mdi:audio-video
entities:
- group.nas_home
- media_player.stue
nas_home:
name: NAS
control: hidden
entities:
- switch.nas411_wol
There are in addition to the four “button”-sensors, two other sensors:
binary_sensor.ha_mode, is just for display in the GUI so when a button is selected, the correct icon will be displayed in yellow (when you click on it).
sensor.ha_mode, is for storing the button-value selected for using in later logic like scenes etc…
in witch files do i have to paste the parts of the config you shared?
thanks in advance!
Look at the code and you will see #File: «the file name»
Thank you verry much, it’s working fine at the moment and i can select a mode!
now i have the folowing problem, I’m having the same switch as the picture above and trying to set the mode by the 2-wall switch. it’s sending 2 codes. code 1 on and off and code 2 on and off.
What am i doing wrong and how do i get this thing work?
I have made the following code for it;
alias: thuis (home) stand inschakelen
trigger:
platform: state
entity_id: switch.modus_schakelaar_thuis_of_slapen_gang_beneden
to: ‘on’
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_mode_home
alias: Slapen (night) stand inschakelen
trigger:
platform: state
entity_id: switch.modus_schakelaar_thuis_of_slapen_gang_beneden
to: ‘off’
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_mode_night
alias: Afwezig (away) stand inschakelen
trigger:
platform: state
entity_id: switch.modus_schakelaar_afwezig_of_vakantie_gang_beneden
to: ‘on’
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_mode_away
alias: Vakantie (holiday) stand inschakelen
trigger:
platform: state
entity_id: switch.modus_schakelaar_thuis_of_slapen_gang_beneden
to: ‘off’
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_mode_holiday
thanks in advance!
I don’t understand this sentence (?). But I read it like a switch can have an "on" and "off" state. And you have two of these.
Try:
from: ‘off’
to: ‘on’
Please format your code with the “</>”-button like:
- alias: thuis (home) stand inschakelen
trigger:
platform: state
entity_id: switch.modus_schakelaar_thuis_of_slapen_gang_beneden
to: 'on'
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_mode_home
I don’t see anything wrong with your code.