Create template-sensor through API?

I am looking for a way to configure a new template-sensor programatically. That is, I neither want to somehow touch configuration.yaml, nor manually click through the GUI-based dialog.

If I have all the options that I would need to configure for a new template via either mechanism, is there a way to do so e.g. through the API from the outside? Maybe I should check how “Repairs” work?

As background-info, I’m kind of developing a setup-assistant.

Thanks in advance for any tips & pointers! The keywords are unfortunately too overloaded so that I did not spot any existing info.

-Volker

1 Like

I don’t know if there is such API but there is a way to separate your configuration from other configurations: Packages - Home Assistant

1 Like

Thanks, that’d be a partial solution but I’m looking for one that requires no user-intervention.

See below link for some pointers. I wrote this as a custom template helper via UI just before it was included in the core.

Basically create a SensorTemplate entity in your code.

1 Like

Not possible. You have to touch yaml files. There is no API for HA to create sensors & entities on the fly outside websockets. And websockets don’t handle the config entry generation.

1 Like

<LayoutModificationTemplate xmlns="http://
schemas.microsoft.com/Start/2014/
LayoutModification"
xmlns:defaultlayout="http://
schemas.microsoft.com/Start/2014/
FullDefaultLayout" xmlns:start="http://
schemas.microsoft.com/Start/2014/
StartLayout" Version="1">
<LayoutOptions
StartTileGroupCellWidth="6"/>
<RequiredStartGroupsCollection>
<RequiredStartGroups>
<AppendGroup>
<start:Tile
AppUserModelID="AD2F1837.myHP_
v10z8vja
g6ke6!App" Size="2x2" Row="0" Column="0"/>
<start:Tile
AppUserModelID="AD2F1837.OMENComman
dCenter
_
v10z8vjag6ke6!
AD2F1837.OMENCommandCenter" Size="2x2"
Row="0" Column="2"/>
<start:Tile
AppUserModelID="4DF9E0F8.Netflix
_
qhnhss8!Netflix.App" Size="2x2" Row="0"
Column="4"/>
mcm4nj
<start:Tile
AppUserModelID="5A894077.McAfeeSecurity
_
wafk5atnkzcwy!App" Size="2x2" Row="2"
Column="0"/>
<start:Tile
AppUserModelID="PricelinePartnerNetwork.
Booking.comUSABigsavingson_mgae2k3ys4
ra0!App" Size="2x2" Row="2" Column="2"/>
<start:Tile
AppUserModelID="AD2F1837.HPQuickDrop_
v
10z8vjag6ke6!App" Size="1x1" Row="4"
Column="2"/>
<start:DesktopApplicationTile
DesktopApplicationLinkPath="C:
\ProgramData\Microsoft\Windows\Start
Menu\Programs\Walmart.lnk" Size="2x2"
Row="2" Column="4"/>
<start:DesktopApplicationTile
DesktopApplicationLinkPath="C:
\ProgramData\Microsoft\Windows\Start
Menu\Programs\LastPass.lnk" Size="2x2"
Row="4" Column="0"/>
<start:DesktopApplicationTile
DesktopApplicationLinkPath="C:
\ProgramData\Microsoft\Windows\Start
Menu\Programs\ExpressVPN.lnk" Size="1x1"
Row="4" Column="3"/>
<start:DesktopApplicationTile
DesktopApplicationLinkPath="C:
\ProgramData\Microsoft\Windows\Start
Menu\Programs\WildTangent Games.lnk"
Size="1x1" Row="5" Column="2"/>
<start:Tile
AppUserModelID="26720RandomSaladGame
sLLC.SimpleSolitaire_
kx24dqmazqk8j!App"
Size="1x1" Row="5" Column="3"/>
</AppendGroup>
</RequiredStartGroups>
</RequiredStartGroupsCollection>
</LayoutModificationTemplate>